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 #5649

Closed
alexlamsl opened this issue Sep 7, 2022 · 0 comments · Fixed by #5650
Closed

ufuzz failure #5649

alexlamsl opened this issue Sep 7, 2022 · 0 comments · Fixed by #5650
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

try {
    {
        var brake2 = 5;
        while (--b + (b = a) && --brake2 > 0) {
            var Infinity_1 = function f0(foo, {}) {
                function f1(foo, arguments) {
                    c = c + 1;
                    try {
                        {
                            throw c = 1 + c, 4 << "undefined" > (arguments && (arguments.undefined >>>= undefined == {})) === ("undefined" && "number" || 0 % []);
                        }
                    } catch (b_2) {
                        c = 1 + c, +3 << (NaN << "") ^ (true !== "foo") > 2 >> "undefined";
                    }
                    {
                        throw typeof foo == "function" && --_calls_ >= 0 && foo`\`${c = 1 + c, 
                        ((23..toString() >>> []) - ("number" == "foo")) % (("c" != NaN) > (22 < this))} `;
                    }
                }
                var a_1 = f1(undefined);
                function f2(yield_1, foo_2) {}
                var foo = f2(false);
            }(undefined, {
                var: -3,
                undefined: --b + [ (c = c + 1) + {
                    foo: a++ + --a
                }.then, {
                    value: (c = c + 1) + (a && a.null)
                }[(a && a.c || 2).toString()[/[abc4]/.test(((c = c + 1) + +b || b || 5).toString())]] ][25]
            });
        }
    }
} catch (a_1) {} finally {}

c = c + 1;

try {
    try {
        {
            var brake12 = 5;
            while (void ((true + "object") % (25 ^ -3) & (-2 << "" ^ 0 != "a")) && --brake12 > 0) {
                try {
                    {
                        var expr14 = --b + (--_calls_ >= 0 && f2());
                        for (Infinity_1 in expr14) {
                            switch (a++ + --b) {
                              case a++ + (a++ + b-- || 2).toString()[[ (c = c + 1) + (a++ + (c = 1 + c, 
                                ((25 ^ 24..toString()) === (c = c + 1, "object")) % (false ^ "b" || "foo" >>> "foo"))), [ (c = 1 + c, 
                                Infinity_1 && (Infinity_1[(c = c + 1) + {}] &= ("c" <= "number") >>> (3 === 24..toString()) !== (-3 % "number" == ({} ^ undefined)))) ].in, a++ + typeof let_2 ].then]:
                                break;

                              case b--:
                                var c_1 = (c = c + 1) + (Infinity_1 && typeof Infinity_1.foo == "function" && --_calls_ >= 0 && Infinity_1.foo());
                                {
                                    var b_1 = function f3(arguments_1) {
                                        function f4() {
                                        }
                                        var a_1 = f4((c = 1 + c, "b" + -1 == -1 >= "c" & 25 >= -4 < (24..toString() && 5)), (c = 1 + c, 
                                        true * -3 <= (Infinity_1 && ([ Infinity_1[c = 1 + c, 
                                        {} << 5 < void -3 > (false >= 2) >>> (-0, 
                                        NaN)] ] = [ -5 + 24..toString() ])) != ("function" >>> -0) / (true < !0o644n)), (c = 1 + c, 
                                        c_1 = ("bar" || 0) > (Infinity_1 *= 4 ^ 23..toString()) < (4 > "function" | 3 <= 2)));
                                        function f5(await_1) {
                                        }
                                        var Infinity_1 = f5((c = 1 + c, (-4 >> NaN != "c" <= "object") - (delete undefined >> (24..toString() << "number"))));
                                    }();
                                }
                                break;

                              case (c = c + 1) + (c_1 && typeof c_1.get == "function" && --_calls_ >= 0 && c_1.get(a++ + ((c = c + 1) + void (("b" ^ (-42n).toString() && [ , 0 ].length === 2 !== "b") / ((38..toString() <= -5) >> (1 <= -0))) ? +a : a++), (c = c + 1) + [ --b + ("a" in {
                                    undefined: (c = 1 + c, (5 !== 25 == 25 / []) + delete (0 ^ "a"))
                                }) ], -2)):
                                ;
                                break;

                              case b_1 && b_1[--b + ((c = c + 1) + {
                                    next: 1 === 1 ? a : b,
                                    async: --b + ((("a", [ , 0 ][1]) == "foo" >= 5) << ((b_1 && (b_1[c = 1 + c, 
                                    23..toString() === -3 == ([], 24..toString()) && ("foo" !== this) >= 1 % [ , 0 ][1]] = ([ , 0 ].length === 2) >>> 23..toString())) <= (false, 
                                    "function"))),
                                    length: a++ + (--_calls_ >= 0 && f2` 
${c = 1 + c, delete ((undefined ^ "function") == "c" >>> 0)}`),
                                    "": +function c_2() {
                                    }()
                                }.var || a || 3).toString()]:
                                break;
                            }
                        }
                    }
                } catch (let_1) {}
            }
        }
    } catch (b_2) {
        {
            var b_1 = function f6(yield, b_2, bar) {
                {
                    var brake22 = 5;
                    L44197: do {
                        {
                            var c = function f7(b_2, c_2) {
                                c = 1 + c, ((/[a2][^e]+$/, 4) ^ -0 % "foo") << ((-1 & "function") <= (-1 || -1));
                            }("b", --b + (typeof Infinity_1 == "function" && --_calls_ >= 0 && Infinity_1(-5)), typeof f3 == "function" && --_calls_ >= 0 && f3());
                        }
                    } while ((c = c + 1) + a++ && --brake22 > 0);
                }
            }(25, b++, a++ + {
                0: typeof Infinity_1 == "function" && --_calls_ >= 0 && Infinity_1(--b, NaN, this)
            }[function() {
                {
                    var brake20 = 5;
                    do {
                        c = c + 1;
                    } while ((c = c + 1) + (b_2 = 0 === 1 ? a : b) && --brake20 > 0);
                }
            }]);
        }
    } finally {}
} catch (yield_1) {
    c = c + 1;
    if (--b + [ --b + (yield_1 += --b + [ yield_1 && typeof yield_1.then == "function" && --_calls_ >= 0 && yield_1.then([ (c = 1 + c, 
    ("function" >>> "a" && -2 | false) - (-3 - -3 === "function" - false)), (c = 1 + c, 
    Infinity_1 && (Infinity_1[/[abc4]/.test(((0 === 1 ? a : b) || b || 5).toString())] += ((yield_1 && (yield_1.var = 2 || -4)) < (Infinity_1 && (Infinity_1[c = 1 + c, 
    4 >>> "a" << (([ , 0 ].length === 2) << NaN) ^ (Infinity === "b") - (0 & 3)] /= 3 >> 38..toString()))) >> (2 < false == (/[a2][^e]+$/ == false)))) ].set, ..."" + yield_1) ].set) ].length) {
        var brake27 = 5;
        L44198: while (a++ + a++ && --brake27 > 0) {
            for (var brake28 = 5; --b + {
                ...Infinity_1
            }[(c = c + 1) + (Infinity_1 && Infinity_1.foo ? 1 === 1 ? a : b : a++ + (typeof alias1 != "undefined" && alias1))] && brake28 > 0; --brake28) {
                1 === 1 ? a : b;
            }
        }
    } else {
        c = c + 1;
    }
    {
        var bar = function c_1() {
            function f8(a_1, yield, yield_1) {
                for (var brake32 = 5; b-- && brake32 > 0; --brake32) {
                    var brake33 = 5;
                    do {
                        c = 1 + c, a_1 += (null >>> "bar" & 4 <= 25) % (+"object" * (c = c + 1, 
                        null));
                    } while ((c = 1 + c, c = c + 1, -3 === "object" ^ -1 != 38..toString()) && --brake33 > 0);
                }
            }
            var arguments = f8(yield_1 && typeof yield_1.async == "function" && --_calls_ >= 0 && (--b + ((c = 1 + c, 
            ("b" ^ "object") / ("a" << {}) * (/[a2][^e]+$/ & 23..toString() || 2 != 22)) || 1).toString()[c = 1 + c, 
            (-3 >= 24..toString(), "" + "undefined") / (1 << "a" && 1 >> 22)], yield_1.async)((c = 1 + c, 
            (null === 1) + (true < 1) ^ ((4 || false) | "foo" === "number"))), ..."" + yield_1);
            function f9(b_1, arguments_2, a_2) {
                function f10(b, foo_2, arguments_2) {
                    c = 1 + c, ((38..toString() > 22) + (5 - "a")) % ((Infinity > undefined) / -38..toString());
                }
                var let_1 = f10();
                function f11(foo_1, await_1, foo) {
                    c = 1 + c, (-2 >> true > (true < "foo")) * ((23..toString(), 
                    38..toString()) / (c = c + 1, "b"));
                    c = 1 + c, let_1 && (let_1[[ (c = 1 + c, 2 ^ Infinity ^ 24..toString() + ([ , 0 ].length === 2) ^ (b_1 && (b_1[c = 1 + c, 
                    void "function" && -2 == -4 || ("function" & 2) == "b" * 4] = null | 22)) != "function" << true) ][a_2 && a_2.Infinity]] %= ("" | -2) % (-5 ^ true) !== (arguments && (arguments.null = ("object" ^ 23..toString()) !== (arguments_2 && (arguments_2[c = 1 + c, 
                    ((b_1 = 2 - [ , 0 ][1]) | (Infinity_1 = NaN ^ -1)) ^ (arguments && (arguments.then += -1 ^ [])) << ("a" | 23..toString())] /= ("object", 
                    -4))))));
                }
                var foo = f11(typeof f9 == "function" && --_calls_ >= 0 && f9((c = 1 + c, 
                (-3 + undefined ^ -2 & 3) == (-5 - false) % (-3 >>> -3)), (c = 1 + c, 
                22 * 23..toString() / (c = c + 1, 23..toString()) / (-4 * 1 < (/[a2][^e]+$/ == ""))), ..."" + a_2), [ (c = 1 + c, 
                (-4 ^ "c") > 25 << "" === ("foo" >> true) ** (Infinity + ([ , 0 ].length === 2))), (c = 1 + c, 
                ("" - -1) * (25 >> "function"), (c = c + 1, Infinity) <= (24..toString() >= [ , 0 ][1])) ].static, a++ + new function(async) {
                    this.a |= NaN && 23..toString();
                }("foo", -3));
                function f12(await_1, await_1, arguments_1) {}
                var a_1 = f12``;
            }
            var arguments_1 = f9("b", --b + !((arguments_1 && (arguments_1.set = [] != 38..toString())) % (Number(0xdeadn << 16n | 0xbeefn) >= 23..toString()) && ([ , 0 ].length === 2 != 5) * (4 !== false)), 24..toString());
            function f13() {
                c = c + 1;
                {
                    var foo = function f14(b_1, Infinity_1_1, arguments_1) {
                    }(38..toString(), (c = 1 + c, (yield_1 && (yield_1.c >>= "c" + "undefined" || +this)) | ("object" | "c") ^ 1 + false), (c = 1 + c, 
                    (yield_1 && (yield_1.next += (c = c + 1, -2) & ("number" & /[a2][^e]+$/))) >>> (null + -5 >>> (-0 > 23..toString()))));
                }
            }
            var foo_2 = f13(22, (c = c + 1) + typeof NaN_2, a++ + ((c = 1 + c, 24..toString() == 1 && -"b" || (38..toString() | 2 || Infinity_1 && (Infinity_1.b += true < [ , 0 ][1]))) || 3).toString()[(c = c + 1) + yield_1]);
            function f15(a_2) {
                typeof f13 == "function" && --_calls_ >= 0 && f13((c = 1 + c, ((this != {}) > "" - /[a2][^e]+$/) % ((Infinity_1 && (Infinity_1[c = 1 + c, 
                ("" >>> 22 <= (arguments_1 && (arguments_1.null *= "b" << -1))) % ((25 << /[a2][^e]+$/) * ([ , 0 ][1] > "b"))] += "number" < 3)) == 38..toString() * this)), (c = 1 + c, 
                (25 <= "c" == ("undefined" ^ "bar")) + (-3 >> "object" ^ NaN >> 24..toString())));
                {
                    var brake41 = 5;
                    while (typeof a_2 == "function" && --_calls_ >= 0 && a_2() && --brake41 > 0) {
                        var expr42 = (c = 1 + c, (1 > NaN, 22 + 5) & (Infinity_1 && (Infinity_1[[ (c = 1 + c, 
                        Infinity_1 && (Infinity_1.Infinity += ((yield_1 && ([ yield_1.then ] = [ null << "number" ])) ^ (-0 ^ -4)) >>> (yield_1 /= NaN + "foo" != (c = c + 1, 
                        [ , 0 ].length === 2)))), (c = 1 + c, (Infinity_1 = 4 + "bar" >= ("c" & 5)) != "object" > 2 < undefined >>> [ , 0 ][1]), (c = 1 + c, 
                        25 > -4 <= (this != "c"), ("undefined", /[a2][^e]+$/) & false / -5) ]] = (arguments_1 && ([ arguments_1[c = 1 + c, 
                        24..toString() % -0 << (22 <= 24..toString()) & ("function" || undefined) > ([ , 0 ].length === 2 == null)] ] = [ "c" - "" ])) + (Infinity_1 && (Infinity_1[c = 1 + c, 
                        (-2 && [ , 0 ].length === 2) ^ ("object" || 3) | (yield_1 && (yield_1[(c = c + 1) + [ (c = 1 + c, 
                        (-3, "number") % (-2 + undefined) % (("" == 22) / ("function" === this))), (c = 1 + c, 
                        ((-0 && 4) >= (([ , 0 ].length === 2) <= 1)) + ((-0 >>> -2) + (2 + 38..toString()))) ][c = 1 + c, 
                        (this || "object") ^ "a" == null, (this < 5) >>> ("" << -5)]] >>= (5 ^ 5) << (Infinity >> "object")))] = 38..toString() >= 5)))));
                        for (var key42 in expr42) {
                            c = 1 + c;
                            var b_2 = expr42[key42];
                            c = 1 + c, (arguments_1 && ([ arguments_1.b ] = [ Infinity + false < ([ , 0 ][1] === 25) ])) + (key42 && (key42[[ (c = 1 + c, 
                            ("bar" <= this, 1 < 2) >>> ((a_2 <<= "b" && "undefined") ^ [] * "function")) ][c = 1 + c, 
                            (b_2 = (NaN <= {}) / (/[a2][^e]+$/ && 22)) !== ("b" >= 3 && false ^ "foo")]] ^= ("a", 
                            "c") + (arguments_1 && ({
                                b: arguments_1[c = 1 + c, (NaN != /[a2][^e]+$/) - (NaN >> "b") >> !(25 + {})]
                            } = {
                                b: ("function", 38..toString())
                            }))));
                        }
                    }
                }
            }
            var Infinity_1 = f15(-4);
        }();
    }
}

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

try {
    for (var brake2 = 5; --b + (b = a) && 0 < --brake2; ) {
        --b, a++, c = c + 1 + 1, --a && a.null, (a && a.c || 2).toString()[/[abc4]/.test(((c += 1) + +b || b || 5).toString())];
        var Infinity_1 = void function() {
            c += 1;
            try {
                c = 1 + c;
            } catch (n) {
                c = 1 + c;
            }
            throw !1;
        }();
    }
} catch (c) {}

c += 1;

try {
    try {
        var c_1, expr14, brake12 = 5;
    } catch (c) {
        var b_1 = function() {
            for (var c = 5; --b, "function" == typeof Infinity_1 && 0 <= --_calls_ && Infinity_1(-5), 
            "function" == typeof f3 && 0 <= --_calls_ && f3(), NaN + a++ && 0 < --c; ) {}
        }((b++, a++, "function" == typeof Infinity_1 && 0 <= --_calls_ && Infinity_1(--b, NaN, this)));
    }
} catch (e) {
    if (c += 1, --b + [ --b + (e += --b + [ e && "function" == typeof e.then && 0 <= --_calls_ && e.then([ 0, (c = 1 + (1 + c), 
    Infinity_1 && (Infinity_1[/[abc4]/.test((b || 5).toString())] += ((e && (e.var = 2)) < (Infinity_1 && (Infinity_1[c = 1 + c, 
    4 << ((2 === [ , 0 ].length) << NaN) ^ 0] /= 0))) >> !0)) ].set, ..."" + e) ].set) ].length) {
        for (var brake27 = 5; a++ + a++ && 0 < --brake27; ) {
            for (var brake28 = 5; --b + {
                ...Infinity_1
            }[(c += 1) + (Infinity_1 && Infinity_1.foo ? a : a++ + ("undefined" != typeof alias1 && alias1))] && 0 < brake28; --brake28) {}
        }
    } else {
        c += 1;
    }
    var bar = function() {
        e && "function" == typeof e.async && 0 <= --_calls_ && (--b, c = 1 + (1 + c), 
        e.async)((c = 1 + c, 4));
        for (var n = 5; b-- && 0 < n; --n) {
            for (var t = 5; c = 1 + (1 + c + 1), c += 1, 0 < --t; ) {}
        }
        var i = function n(i, f, e) {
            var o = void (c = 1 + c);
            !function(n, t, a) {
                c = 1 + c, c = 1 + (c += 1), o && (o[[ (c = 1 + c, 2 ^ "24" + (2 === [ , 0 ].length) ^ 0 != (i && (i[c = 1 + c, 
                !1] = 22))) ][e && e.Infinity]] %= -2 !== (arguments && (arguments.null = 23 !== (f && (f[c = 1 + c, 
                ((i = 2) | (l = -1)) ^ (arguments && (arguments.then += -1)) << 23] /= -4)))));
            }(0 <= --_calls_ && n(!1, (c = 1 + (c = 1 + c), 506 / (c += 1, "23") / !0), ..."" + e), [ (c = 1 + c, 
            !1 === 0 ** (1 / 0 + (2 === [ , 0 ].length))), (c = 1 + c, c += 1, !1) ].static, a++ + new function(c) {
                this.a |= NaN;
            }()), function(c, c, n) {}``;
        }("b", --b + !(void 0 % ("23" <= +("" + (0xdeadn << 16n | 0xbeefn))) && !0 * (2 === [ , 0 ].length != 5)), "24");
        function f() {
            c = 1 + (c += 1), e && (e.c >>= "cundefined"), c = 1 + c, e && (e.next += 0 & (c += 1, 
            -2));
        }
        f(c += 1, (a++, c = 1 + c, c += 1));
        var l = function(n) {
            0 <= --_calls_ && f((c = 1 + c, l && (l[c = 1 + c, (0 <= (i && (i.null *= 0))) % 0] += !1)), c = 1 + c);
            for (var t, a = 5; "function" == typeof n && 0 <= --_calls_ && n() && 0 < --a; ) {
                for (t in c = 1 + c, 27 & (l && (l[[ (c = 1 + c, l && (l.Infinity += (-4 ^ (e && ([ e.then ] = [ 0 ]))) >>> (e /= "NaNfoo" != (c += 1, 
                2 === [ , 0 ].length)))), 0 != (l = !1), (c = 1 + (1 + c), 0) ]] = (i && ([ i[c = 1 + c, 
                0 & (2 === [ , 0 ].length == null) < "function"] ] = [ NaN ])) + (l && (l[c = 1 + c, 
                2 === [ , 0 ].length ^ "object" | (e && (e[(c += 1) + [ NaN % (!1 / ("function" === this)), (c = 1 + (1 + c), 
                ((2 === [ , 0 ].length) <= 1 <= -0) + "0238") ][c = 1 + c, (this < 5) >>> 0]] >>= 0))] = !0))))) {
                    c = 1 + (1 + c), i && ([ i.b ] = [ !1 ]), t && (t[[ !0 >>> (NaN ^ (n <<= "undefined")) ][c = 1 + (1 + c), 
                    !0]] ^= "c" + (i && ({
                        b: i[c = 1 + c, 1]
                    } = {
                        b: "38"
                    })));
                }
            }
        }(-4);
    }();
}

console.log(null, a, b, c, 1 / 0, NaN, void 0);
original result:
null 100 99 7 Infinity NaN undefined

uglified result:
null 100 99 6 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
try {
    function f1() {
        try {
            throw 0 > 0;
        } catch (b_2) {
            console.log();
        }
        throw 0 == 1;
    }
    f1();
} catch (a_1) {}
// (stringified)
// output: "\n"
// minify: ""
// 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:
  evaluate
  if_return
  passes
  reduce_vars
  side_effects
  unused
@alexlamsl alexlamsl added the bug label Sep 7, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Sep 7, 2022
alexlamsl added a commit that referenced this issue Sep 8, 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