Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ufuzz failure #5634

Closed
alexlamsl opened this issue Aug 29, 2022 · 0 comments · Fixed by #5635
Closed

ufuzz failure #5634

alexlamsl opened this issue Aug 29, 2022 · 0 comments · Fixed by #5635
Labels

Comments

@alexlamsl
Copy link
Collaborator

// original code
// (beautified)
var _calls_ = 10, a = 100, b = 10, c = 0;

{
    var expr1 = "a";
    for (a in expr1) {
        c = 1 + c;
        var bar = expr1[a];
        {
            var b_1 = async function async_2() {
                function f0() {
                    switch ([ (c = 1 + c, ("c" < "b") + ([] <= -0), (22 | -3) - (-2 >= 5)) ][(c = c + 1) + (typeof bar_2 !== "undefined")]) {
                      case a++ + a--:
                        {
                            var brake5 = 5;
                            while ((c = 1 + c, (Infinity | 23..toString() | NaN >> 5) !== (Infinity == true) < false % "object") && --brake5 > 0) {
                                c = 1 + c, [] >>> -4 >>> ("undefined" | -0) < (([ 3n ][0] > 2 ^ 1) == ("a" != ([ , 0 ].length === 2)));
                            }
                        }
                        {
                        }
                        {
                            var brake8 = 5;
                            while ((c = 1 + c, -3 >> undefined < (3 != undefined) <= ("number" >> -4 ^ null >> 23..toString())) && --brake8 > 0) {
                                c = 1 + c, bar && (bar.a += (1 >>> null, {} !== false)), 
                                (0 > -5) % (2 % true);
                            }
                        }
                        break;

                      case /[abc4]/g.exec((b-- || b || 5).toString()):
                      default:
                        var foo = (c = 1 + c, (bar && (bar[(c = c + 1) + /[abc4]/.test(((c = 1 + c, 
                        ("a" / "" > this - false) >> (24..toString() >= ([ , 0 ].length === 2)) / (0 ^ 25)) || b || 5).toString())] = [ , 0 ][1] < 4 != 1 - 22)) - (c = c + 1, 
                        undefined & 22));
                        switch (c = 1 + c, ((-3 == false) <= (24..toString() <= 22)) - ("object" > 0 ^ (this && -4))) {
                          case c = 1 + c, (([ 3n ][0] > 2) * 1 === (NaN | true)) % (this / 0 < delete this):
                            ;
                            break;

                          case c = 1 + c, ("number" >>> /[a2][^e]+$/ !== (foo && ([ foo[c = 1 + c, 
                            ((foo = 23..toString() | NaN) && Number(0xdeadn << 16n | 0xbeefn) - {}) << ((-3 | false) == "a" * null)] ] = [ -1 - NaN ]))) >>> (Infinity ^ true || !23..toString()):
                            ;
                            break;

                          default:
                            ;

                          case c = 1 + c, (NaN && "undefined") % (-1 << -0) ^ void [ , 0 ][1] - (22 > []):
                            ;
                            break;
                        }

                      case (3 / "" ^ /[a2][^e]+$/ != 3) !== -(24..toString() < "undefined"):
                        if (c = 1 + c, (2 != -1 != [] * undefined) <= (3 >= "b" <= (c = c + 1, 
                        "function"))) {
                            c = 1 + c, delete (false > "" == -true);
                        }
                        switch (c = 1 + c, (24..toString() && undefined) == 24..toString() % "a" != "bar" <= 25 <= (/[a2][^e]+$/ > "b")) {
                          default:
                            ;

                          case c = 1 + c, ("number" - "function" >> (bar && (bar.static &= 0 >>> 1))) / ((4 >= "bar") >>> 38..toString() - 23..toString()):
                            ;
                            break;

                          case c = 1 + c, foo && (foo.set &= (bar && (bar[c = 1 + c, 
                            (-2 !== -5 || -1 === "a") < "" + -3 >>> 3 ** 4] += 1 > 5)) % (NaN ^ -3) >> (3 | false || "bar" / "bar")):
                            ;
                            break;

                          case c = 1 + c, ([ , 0 ].length === 2 != []) + (!0o644n & 23..toString()) ^ (4 ^ -4) + (-3 ^ []):
                            ;
                            break;
                        }
                        {
                            var brake15 = 5;
                            do {
                                c = 1 + c, bar && (bar[--b] %= ([ , 0 ][1] + "" !== (24..toString() === {})) * ((1 !== false) >> (-2, 
                                "number")));
                            } while ((c = 1 + c, -5 * 23..toString() === 38..toString() >> 0 ^ (24..toString() >> this) - ([ , 0 ].length === 2 === 0)) && --brake15 > 0);
                        }
                    }
                    --b;
                }
                var async_1 = f0();
                async function f1() {
                    c = c + 1;
                    try {
                        return {
                            1.5: (c = 1 + c, (24..toString() << []) / (3 && "object") >= ("undefined" - 25 && (3 && true)))
                        };
                    } finally {
                        c = c + 1;
                    }
                }
                var yield = f1([ , 0 ].length === 2);
            }();
        }
    }
}

L18597: {
    {
        var expr24 = --b + {
            a: a,
            "": --b + (0 in {}),
            static: (c = c + 1) + (a = NaN),
            "-2": 0 === 1 ? a : b,
            var: 0 === 1 ? a : b
        };
        for (var key24 in expr24) {
            c = 1 + c;
            var yield = expr24[key24];
            {
                var a_2 = function f2(let_1, foo = --b + [ yield += /[abc4]/g.exec((a++ + b++ || b || 5).toString()) ][a++ + (typeof f3 == "function" && --_calls_ >= 0 && f3())], a_1) {
                    c = c + 1;
                    {
                        if ([ (c = 1 + c, a_1 && (a_1.null = 25 < "b" <= ("bar", 
                        -3) >= (let_1 && (let_1.a = (c = c + 1, -4) === ("" != []))))) ][(c = c + 1) + void a]) {
                            c = 1 + c, (25 - 2 ^ "undefined" !== "undefined") + (("a" == "function") + ("object" << 4));
                        }
                        {
                            var key24_1 = function f3(b_2, let_1) {
                                c = 1 + c, (4 <= -4 ^ "foo" < "number") >= (foo >>= "object" + 23..toString()) % (25 >> null);
                            }();
                        }
                        if (a++ + (typeof f0 == "function" && --_calls_ >= 0 && f0())) {
                            switch (delete (((true || "object") < (null !== "foo")) >> (22 < 0 >= (let_1 = 38..toString() - -0)))) {
                              default:
                              case typeof f4 == "function" && --_calls_ >= 0 && f4((c = 1 + c, 
                                (key24 = "object" >> "a") && -1 + "a" || (this ^ -3) < (c = c + 1, 
                                [ , 0 ].length === 2)), ..."" + key24_1):
                                c = 1 + c, ("object" >> {} >> Infinity * ([ , 0 ].length === 2)) / (this > this !== (-5 !== 5));
                                c = 1 + c, (-5 >= -5 && "foo" & 5) >> (-5 ^ 4 && -0 >> null);
                                c = 1 + c, (yield += (38..toString(), "bar")) < "bar" >> 5 || this / "undefined" << (NaN < Infinity);
                                break;

                              case []:
                                break;

                              case --b + b++:
                                c = 1 + c, ([ 3n ][0] > 2 === 2 & (foo && (foo[c = 1 + c, 
                                delete ({} ^ Infinity) && (key24_1 && ([ key24_1[c = 1 + c, 
                                ([] | 1) + ([ , 0 ][1] === 1) | true * "bar" >> (c = c + 1, 
                                undefined)] ] = [ 0 ^ -4 ])) << (-1, -0)] += ([ , 0 ][1], 
                                "")))) * -(-2 % Infinity);
                                c = 1 + c, a_1 && (a_1.then >>>= (yield && (yield.next += 24..toString() > 0)) / (this || true) && Infinity - "function" | (this || undefined));
                                break;
                            }
                        } else {
                            var bar_1;
                        }
                        NaN;
                    }
                    {
                        var expr42 = --b + (-1 - 24..toString() >> ("function" || 3)) * (null - {} > delete 22);
                        for (yield in expr42) {
                            c = 1 + c;
                            var arguments = expr42[yield];
                            c = c + 1;
                        }
                    }
                }("function");
            }
        }
    }
}

try {
    L18598: {
        for (var brake46 = 5; a++ + a++ && brake46 > 0; --brake46) {
            var brake47 = 5;
            while (a++ + 38..toString() && --brake47 > 0) {
                var yield = typeof yield == "function" && --_calls_ >= 0 && yield(a++ + (yield += yield && (yield[--b + [ (c = 1 + c, 
                (yield && (yield.a += NaN !== Infinity == (c = c + 1, "object"))) & (yield && (yield.Infinity += -3 == -0 != -0 >> -0))) ]] = 4 + 38..toString() >= (yield += 4 & "object") ^ +"" != (/[a2][^e]+$/ && "b"))), -5);
            }
        }
        var arguments = a++ + b++;
    }
} catch (NaN) {
    ((undefined != -4) > [] << 38..toString()) >> (([ , 0 ][1] ^ 1) <= (NaN && (NaN.set = NaN + null)));
} finally {
    {
        var brake52 = 5;
        L18599: while (--b + (a && typeof a.a == "function" && --_calls_ >= 0 && a.a(-5, -1)) && --brake52 > 0) {
            var async = {
                3: a++ + {
                    get: typeof bar === "number"
                }.get,
                "": --b + `${(c = c + 1) + (this in {
                    then: (c = 1 + c, (a && (a.a = "a" === 0)) % (NaN - "") != (false >= Infinity ^ "function" <= NaN))
                } || 7).toString()[((a = false % -1) ^ (a && (a[c = 1 + c, void (-0 < undefined < ("function" < this))] += "object" << this))) >> ({} != 0 != 1 >= 2)]}
${typeof (--b + (typeof f0 == "function" && --_calls_ >= 0 && f0("function")) || 6).toString()[a++ + (a && a[c = 1 + c, 
                (([ , 0 ].length === 2) > true && -2 ^ 25) === -4 / 0 - (a &= false >= undefined)])]}
${(++a || a || 3).toString()}
${a}
 
${--b + a}`
            }, a_2 = ((c = c + 1) + (a && typeof a.set == "function" && --_calls_ >= 0 && (b++, 
            a.set)()) || 6).toString()[--b + (a++ + `` ? (c = c + 1) + ++a : 1 === 1 ? a : b)];
        }
    }
}

console.log(null, a, b, c, Infinity, NaN, undefined);
// uglified code
// (beautified)
var _calls_ = 10, a = 100, b = 10, c = 0, expr1 = "a";

for (a in expr1) {
    var c = 1 + c, bar = expr1[a], b_1 = async function() {
        !function() {
            switch ([ (c = 1 + c, -1) ][(c += 1) + ("undefined" != typeof bar_2)]) {
              case a++ + a--:
                for (var e = 5; c = 1 + c, 0 < --e; ) {
                    c = 1 + c;
                }
                c = 1 + c;
                break;

              case /[abc4]/g.exec((b-- || b || 5).toString()):
              default:
                c = 1 + c;
                var t = +(bar && (bar[(c += 1) + /[abc4]/.test((c = 1 + c, ((this - !1 < NaN) >> ((2 === [ , 0 ].length) <= "24") / 25 || b || 5).toString()))] = !0));
                switch (!0 - (!1 ^ (this && -4))) {
                  case c = 1 + (c = 1 + (c += 1)), (1 == +(2 < 3n)) % (this / 0 < !0):
                  case c = 1 + c, (0 !== (t && ([ t[c = 1 + c, t = 23, "" + (0xdeadn << 16n | 0xbeefn) - {} << !1] ] = [ NaN ]))) >>> 1:
                    break;

                  default:
                  case c = 1 + c, 0:
                }

              case !0:
                switch (c = 1 + c, !0) {
                  default:
                  case c = 1 + (c = 1 + (c += 1)), (NaN >> (bar && (bar.static &= 0))) / 0:
                  case c = 1 + c, t && (t.set &= (bar && (bar[c = 1 + c, !0] += !1)) % -3 >> 3):
                  case c = 1 + c, (2 === [ , 0 ].length != []) + (!0o644n & "23") ^ -11:
                }
                for (var i = 5; c = 1 + c, bar && (bar[--b] %= 1), c = 1 + c, !1 ^ ("24" >> this) - (2 === [ , 0 ].length === 0) && 0 < --i; ) {}
            }
            --b;
        }(), c += 1;
        try {
            await {
                1.5: (c = 1 + c, !1)
            };
        } finally {
            c += 1;
        }
    }();
}

var key24, expr24 = --b + {
    a: a,
    "": --b + (0 in {}),
    static: (c += 1) + (a = NaN),
    "-2": b,
    var: b
};

for (key24 in expr24) {
    c = 1 + c;
    var yield = expr24[key24], a_2 = function(e = --b + [ yield += /[abc4]/g.exec((a++ + b++ || b || 5).toString()) ][a++ + ("function" == typeof f3 && 0 <= --_calls_ && f3())]) {
        c = 1 + ([ void (c = 1 + (c + 1)) ][(c += 1) + void 0] ? 1 + c : c);
        var t = void (e >>= "object23");
        if (a++ + ("function" == typeof f0 && 0 <= --_calls_ && f0())) {
            switch (!0) {
              default:
              case "function" == typeof f4 && 0 <= --_calls_ && f4((c = 1 + c, key24 = 0, 
                (-3 ^ this) < (c += 1, 2 === [ , 0 ].length)), ..."" + t):
                c = 1 + (1 + (1 + c)), yield += "bar";
                break;

              case --b + b++:
                c = 1 + c, e && (e[c = 1 + c, (t && ([ t[c = 1 + c, 1 | NaN >> void (c += 1)] ] = [ -4 ])) << -0] += ""), 
                c = 1 + c;
            }
        }
        for (yield in --b) {
            c = 1 + c, c += 1;
        }
    }();
}

try {
    for (var brake46 = 5; a++ + a++ && 0 < brake46; --brake46) {
        for (var brake47 = 5; a++, 0 < --brake47; ) {
            yield = "function" == typeof yield && 0 <= --_calls_ && yield(a++ + (yield += yield && (yield[--b + [ (c = 1 + c, 
            (yield && (yield.a += 1 == (c += 1, "object"))) & (yield && (yield.Infinity += !1))) ]] = (yield += 0) <= "438" ^ !0)), -5);
        }
    }
    var arguments = a++ + b++;
} catch (c) {
    c && (c.set = c + null);
} finally {
    for (var brake52 = 5; --b + (a && "function" == typeof a.a && 0 <= --_calls_ && a.a(-5, -1)) && 0 < --brake52; ) {
        var async = ({
            3: a++ + ("number" == typeof bar),
            "": --b + (`${(c += 1) + ("" + (this in {
                then: (c = 1 + c, (a && (a.a = !1)) % NaN != 0)
            } || 7))[((a = 0) ^ (a && (a[void (c = 1 + c)] += "object" << this))) >> !0]}
${typeof ("" + (--b + ("function" == typeof f0 && 0 <= --_calls_ && f0("function")) || 6))[a++ + (a && a[c = 1 + c, 
            (!0 < (2 === [ , 0 ].length) && -25) === -1 / 0 - (a &= !1)])]}
${(++a || a || 3).toString()}
${a}
 
` + (--b + a))
        }), a_2 = ("" + ((c += 1) + (a && "function" == typeof a.set && 0 <= --_calls_ && (b++, 
        a.set)()) || 6))[--b + (a++ + "" ? (c += 1) + ++a : a)];
    }
}

console.log(null, a, b, c, 1 / 0, NaN, void 0);
original result:
null NaN -15 113 Infinity NaN undefined

uglified result:
null NaN -15 112 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
var expr1 = "a";

(async function async_2() {
    async function f1() {
        try {
            return {};
        } finally {
            c = 0;
        }
    }
    f1();
})();

c;
// output: 
// minify: ReferenceError: c is not defined
// options: {
//   "compress": {
//     "passes": 1000000,
//     "sequences": 1000000,
//     "unsafe": true,
//     "unsafe_Function": true,
//     "unsafe_math": true,
//     "unsafe_proto": true,
//     "unsafe_regexp": true
//   },
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
minify(options):
{
  "compress": {
    "passes": 1000000,
    "sequences": 1000000,
    "unsafe": true,
    "unsafe_Function": true,
    "unsafe_math": true,
    "unsafe_proto": true,
    "unsafe_regexp": true
  },
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  awaits
  inline
  passes
  pure_getters
  reduce_vars
  unsafe
  unused
@alexlamsl alexlamsl added the bug label Aug 29, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Aug 29, 2022
alexlamsl added a commit that referenced this issue Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant