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

Closed
alexlamsl opened this issue Jun 20, 2024 · 0 comments · Fixed by #5859
Closed

ufuzz failure #5857

alexlamsl opened this issue Jun 20, 2024 · 0 comments · Fixed by #5859
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0() {
    {
        var brake1 = 5;
        do {
            try {
                {
                    var bar = function b_1(a) {
                        try {
                            var foo_1 = (c = c + 1) + ((24..toString() >>> -2 ^ (foo_1 >>= 0 || 2)) < NaN / 23..toString() % (-2 <= NaN)), bar_2 = (c = c + 1) + (foo_1 && typeof foo_1.length == "function" && --_calls_ >= 0 && ((c = 1 + c, 
                            (undefined / "undefined" || -5 >> -0) && (Infinity + /[a2][^e]+$/ && 3 * null)) ? (c = 1 + c, 
                            ~("c" === true ^ "" <= "bar")) : (c = 1 + c, ({} < "bar" ^ 24..toString() - NaN) & this >> -5 < (bar_2 *= false == 5)), 
                            foo_1.length)(..."" + a, ..."" + foo_1, ...[ (c = 1 + c, 
                            c = c + 1, +([] && 25)), (c = 1 + c, (delete 2 ^ 24..toString() >= "object") !== (4 === 4) >> (25 >= -4)), (c = 1 + c, 
                            ((-4 && 5) ^ (bar_2 && (bar_2.then = "" + null))) * ((3 || "") >>> ("c" ^ this))), (c = 1 + c, 
                            ("number" && 25 || (c = c + 1, null)) <= (c = c + 1, 
                            "c" || 4)), ...[ (c = 1 + c, (bar_2 && (bar_2.var = "undefined" === 24..toString() == (false ^ "b"))) >> ([] == 24..toString() ?? 4 >>> 3)), (c = 1 + c, 
                            (-3 ^ true) > (22 !== "c") || -3 & /[a2][^e]+$/ | 23..toString() <= Infinity) ] ]));
                        } finally {
                            return;
                            --b + (typeof b_2 != "undefined");
                            {
                                return b += a;
                            }
                        }
                    }((c = c + 1) + bar?.[a++ + (0 === 1 ? a : b)], ...[ --b + +function NaN_2() {
                        var Infinity_1 = (c = 1 + c, + +0 >>> ((NaN_2 && (NaN_2[c = 1 + c, 
                        ![ , 0 ][1] - (c = c + 1, [ , 0 ][1]) && (/[a2][^e]+$/, 
                        null) === (4 ^ this)] += "function" % 2)) | 5 << "object"));
                    }(), --b + (typeof f0 == "function" && --_calls_ >= 0 && f0(1, "bar")), a++ + bar?.[(c = c + 1) + void ((this || -5 || bar && (bar.b = this ^ 25)) >>> ((bar && (bar[c = 1 + c, 
                    c = c + 1, [ , 0 ].length === 2 && 24..toString(), ([ , 0 ].length === 2) << "number" ^ "" != NaN] = "b" !== 5)) ^ 0 & "object"))], {
                        done: (c = 1 + c, (([ , 0 ][1] | null) > (Infinity || 23..toString())) >>> ([] ^ [ , 0 ].length === 2) - !false) ? (c = 1 + c, 
                        (null == [ , 0 ][1]) % (0 >= "number") <= (bar && (bar.then += -0 % undefined <= "function" % ""))) : (c = 1 + c, 
                        ("foo" && 1, undefined != -1) <= (24..toString() ?? NaN) >> (-4, 
                        ""))
                    }, ++a ]);
                }
            } finally {
                {
                    var brake10 = 5;
                    while (typeof (--b + (-5 * 38..toString() < (0 > -4) | ~false / (c = c + 1, 
                    "undefined"))) && --brake10 > 0) {
                        switch (b = a) {
                          case a++ + ~b:
                            break;

                          default:
                            (c = c + 1) + [ (c = 1 + c, c = c + 1, ("function" < "bar") - (25 !== "undefined")), (c = 1 + c, 
                            ("number" && {}) / ("function" - "b") << (("c" | "") <= (bar += "foo" / 0))), (c = 1 + c, 
                            23..toString() * Infinity == -5 <= null ^ 23..toString() + "function" - void ""), (c = 1 + c, 
                            (3 < undefined !== ("foo" && "object")) + ((bar && (bar[c = 1 + c, 
                            ([ , 0 ][1] ^ null) <= ("c" | 2) ^ (5 > undefined) % (-0 ^ Infinity)] >>= 0 == {})) << ([ , 0 ][1] ^ [ , 0 ][1]))), (c = 1 + c, 
                            ({} || 38..toString(), {} + "bar") | 0 < "c" != "object" >> -2) ];
                            {
                                var a_2 = function f1(foo, a_1) {
                                    c = 1 + c, ("number" ^ "function") % (/[a2][^e]+$/ != 5) > (38..toString() === false) / (0, 
                                    "number");
                                    c = 1 + c, (2 === [], 25 || -1) | ("number" ?? 38..toString()) * ([] != "");
                                    c = 1 + c, (/[a2][^e]+$/ + /[a2][^e]+$/) % (NaN < -0) + ("object" >= "a" >= "number" << "a");
                                }((c = c + 1) + (bar && bar[c = 1 + c, (c = c + 1, 
                                -4 * -4) / (4 >= 24..toString() ^ ("function" || "bar"))]));
                            }
                            {
                                var expr17 = a++ + (typeof a_2 == "function" && --_calls_ >= 0 && a_2(Number(0xdeadn << 16n | 0xbeefn), (c = 1 + c, 
                                delete (bar && (bar.done += -3 / 1)) << ("c" / true >= (38..toString() ^ this))), []));
                                L42457: for (var key17 in expr17) {
                                    c = 1 + c;
                                    var foo_2 = expr17[key17];
                                    if ("a" in [ (c = 1 + c, ((a_2 && (a_2.var ??= "a" ?? 22)) > (3 ^ 1)) >> (23..toString() * "object" | 24..toString() + "object")) ]) {} else if (c = 1 + c, 
                                    (foo_2 && ({
                                        null: foo_2[(c = c + 1) + b++]
                                    } = {
                                        null: /[a2][^e]+$/ + "c" && -3 !== 38..toString()
                                    })) * (a_2 && (a_2.then += [] >>> 25 != +5))) {
                                        c = 1 + c, (bar && (bar[--b + !(("foo" === -3 && -undefined) >>> ((a_2 && (a_2[c = 1 + c, 
                                        "" >> "number" == "" + false || ({} !== 23..toString(), 
                                        foo_2 += ("c", "bar"))] += -0 >> this)) > 24..toString() >> -0))] = {} > -4 == /[a2][^e]+$/ >> 38..toString())) ?? -0 - "number" === (bar && (bar.undefined /= "number" ^ /[a2][^e]+$/));
                                    }
                                }
                            }

                          case (c = c + 1) + (b = a):
                            break;

                          case bar:
                            {
                                return -1;
                            }
                            break;
                        }
                    }
                }
                {
                    c = c + 1;
                    {
                        var undefined = function f2(bar) {
                            function f3() {
                            }
                            var a_2 = f3();
                        }(true);
                    }
                    (c = c + 1) + (undefined && undefined[--b + [ (c = 1 + c, ("object" != "foo", 
                    this % {}) !== ("c", "c") >>> /[a2][^e]+$/ + 2), (c = 1 + c, 
                    ((a_2 >>>= 1 >= "b") !== ("object", "")) * ((4 && "undefined") << (1 ^ true))) ].c]);
                    var a_2 = a_2 && a_2[a++ + (-0 in [ (c = 1 + c, (-1 ?? -1) / ("foo" || "function") >= (bar && (bar[c = 1 + c, 
                    (null & NaN) == (a_2 && (a_2[c = 1 + c, +(Number(0xdeadn << 16n | 0xbeefn) - 22 ?? 22 === "function")] -= "object" >= -4)) == Number(0xdeadn << 16n | 0xbeefn) * this * (1 ^ -5)] += 1 >= "a")) >> ("c", 
                    "function")), (c = 1 + c, (a_2 /= (22 | 4) >> (3, 3)) | (arguments_2 && ({
                        a: arguments_2.in
                    } = {
                        a: (a_2 && (a_2.value &= Infinity / "foo")) + ([] - -2)
                    }))), (c = 1 + c, (undefined && (undefined[typeof bar == "function" && --_calls_ >= 0 && bar``] &&= (false & {}) > (2 ^ "undefined"))) >= {} * [ , 0 ][1] % ("number" >> {})) ])], arguments_2 = (c = c + 1) + (undefined && undefined[(c = c + 1) + ~(([ , 0 ][1] >= ([ , 0 ].length === 2) ^ 22 <= NaN) >>> (22 <= /[a2][^e]+$/) / (23..toString() < false))]);
                }
                {
                    var bar = function f4() {
                        function f5() {
                            c = 1 + c, (a_2 = true == this) >= (bar && (bar[c = 1 + c, 
                            ("object" / "function" | 1 !== "foo") + (-1 === "c" ^ "number" < 2)] += [ , 0 ].length === 2 | 1)) > (-1 != [] & null <= true);
                            c = 1 + c, -((a_2 && (a_2[c = 1 + c, ((false, [ , 0 ].length === 2) || (1 ?? 0)) === (NaN != Infinity) >= (-0 != this)] &= "object" >>> null)) !== NaN % -5);
                            c = 1 + c, ((bar && ({
                                undefined: bar[c = 1 + c, (bar && (bar.then = "b" < this)) - ("number" >= 0) >> ((null ^ []) > ("b" | 3))]
                            } = {
                                undefined: -2 ?? [ , 0 ][1]
                            })) ^ -1 + -4) > ("foo" * null ^ (NaN ^ 1));
                        }
                        var a_2 = f5([ , 0 ][1]);
                    }(--b + ((Infinity & 2) * (NaN == -1) ^ (38..toString() > -2) - ("bar" | 38..toString())), "function", (c = c + 1) + --b);
                }
                c = c + 1;
                var b = (c = c + 1) + (b = a) ? (c = c + 1) + [ a++ + (typeof async_2 == "function" && --_calls_ >= 0 && async_2()), a++ + (1 === 1 ? a : b), ...[ -2, a++ + (c = 1 + c, 
                (this >> Infinity ^ this === Infinity) * (([ , 0 ].length === 2, 
                [ , 0 ][1]) & null >> 5)), (c = c + 1, undefined) !== void 0 & 22 * false === !0o644n >>> [ , 0 ][1] ], a++ + 2 ][(--b + [ (c = 1 + c, 
                a_2 && (a_2.value = ((Infinity >= "bar") << (c = c + 1, "c"), 38..toString() == 38..toString() | (-5, 
                "function")))), (c = 1 + c, (/[a2][^e]+$/ !== this) << ("bar" !== "b") ^ (NaN != 24..toString()) * (23..toString() ^ /[a2][^e]+$/)) ] || a || 3).toString()] : a++ + /[abc4]/.test((b + 1 - .1 - .1 - .1 || b || 5).toString()), async_2 = --b + (typeof bar == "function" && --_calls_ >= 0 && bar`\\`);
            }
        } while (--b + (bar && typeof bar.c == "function" && --_calls_ >= 0 && bar.c(..."" + bar)) && --brake1 > 0);
    }
}

var b_2 = f0`${b_2 && b_2.b}`;

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

function f0() {
    var brake1 = 5;
    do {
        try {
            var bar = function(a) {
                try {
                    var foo_1 = (c += 1) + ((24..toString() >>> -2 ^ (foo_1 >>= 2)) < NaN / 23..toString() % !1), bar_2 = (c += 1) + (foo_1 && "function" == typeof foo_1.length && 0 <= --_calls_ && (c = 1 + (c = 1 + c), 
                    24..toString(), bar_2 *= !1, foo_1.length)(..."" + a, ..."" + foo_1, (c = 1 + c, 
                    25), (c = 1 + (c += 1), 0 != (!0 ^ "object" <= 24..toString())), (c = 1 + c, 
                    (5 ^ (bar_2 && (bar_2.then = "null"))) * (3 >>> ("c" ^ this))), (c = 1 + c, 
                    25 <= "c"), (c = 1 + (c += 1), (bar_2 && (bar_2.var = "undefined" === 24..toString() == 0)) >> ([] == 24..toString() ?? 0)), (c = 1 + c, 
                    0 | 23..toString() <= 1 / 0)));
                } finally {
                    return;
                }
            }((c += 1) + bar?.[a++ + b], (--b, function NaN_2() {
                c = 1 + c, NaN_2 && (NaN_2[c = 1 + c, c += 1, null === (4 ^ this)] += NaN);
            }(), --b, "function" == typeof f0 && 0 <= --_calls_ && f0(1, "bar"), 
            a++, c += 1, bar && (bar[c = 1 + c, c += 1, 2 === [ , 0 ].length && 24..toString(), 
            (2 === [ , 0 ].length) << "number" ^ !0] = !0), c = 1 + c, !1 >>> ([] ^ 2 === [ , 0 ].length) - !0 ? (c = 1 + c, 
            bar && (bar.then += -0 % undefined <= NaN)) : (c = 1 + c, 24..toString()), 
            ++a));
        } finally {
            for (var brake10 = 5; --b, 38..toString(), c += 1, 0 < --brake10; ) {
                switch (b = a) {
                  case a++ + ~b:
                    break;

                  default:
                    c = 1 + (c += 1), bar += NaN, c = 1 + (c = 1 + (c += 1)), 23..toString(), 
                    23..toString(), c = 1 + c, bar && (bar[c = 1 + c, !0 ^ (undefined < 5) % 0] >>= 0 == {}), 
                    c = 1 + c;
                    c += 1, bar && bar[c = 1 + c, c += 1, 16 / (24..toString() <= 4 ^ "function")];
                    var key17, a_2 = (c = 1 + c, 38..toString(), void (c = 1 + (c = 1 + c))), expr17 = a++ + ("function" == typeof a_2 && 0 <= --_calls_ && a_2(Number(0xdeadn << 16n | 0xbeefn), (c = 1 + c, 
                    bar && (bar.done += -3), !0 << ((38..toString() ^ this) <= NaN)), []));
                    for (key17 in expr17) {
                        c = 1 + c;
                        var foo_2 = expr17[key17];
                        "a" in [ (c = 1 + c, (2 < (a_2 && (a_2.var ??= "a"))) >> ("object" * 23..toString() | 24..toString() + "object")) ] || (c = 1 + c, 
                        (foo_2 && ({
                            null: foo_2[(c += 1) + b++]
                        } = {
                            null: -3 !== 38..toString()
                        })) * (a_2 && (a_2.then += [] >>> 25 != 5)) && (c = 1 + c, 
                        (bar && (bar[--b + !(!1 >>> ((a_2 && (a_2[c = 1 + c, 23..toString(), 
                        foo_2 += "bar"] += -0 >> this)) > 24..toString() >> -0))] = -4 < {} == /[a2][^e]+$/ >> 38..toString())) ?? (bar && (bar.undefined /= 0))));
                    }

                  case (c += 1) + (b = a):
                    break;

                  case bar:
                    return -1;
                }
            }
            var undefined = void 0, a_2 = (c = c + 1 + 1, undefined && undefined[--b + [ this % {} != 0, (c = 1 + (c = 1 + c), 
            0 * ("" !== (a_2 >>>= !1))) ].c], a_2 && a_2[a++ + (-0 in [ (c = 1 + c, 
            (bar && (bar[c = 1 + c, 0 == (a_2 && (a_2[c = 1 + c, +(Number(0xdeadn << 16n | 0xbeefn) - 22 ?? !1)] -= !1)) == Number(0xdeadn << 16n | 0xbeefn) * this * -6] += !1)) >> "function" <= NaN), (c = 1 + c, 
            (a_2 /= 2) | (arguments_2 && ({
                a: arguments_2.in
            } = {
                a: (a_2 && (a_2.value &= NaN)) + ([] - -2)
            }))), (c = 1 + c, (undefined && (undefined["function" == typeof bar && 0 <= --_calls_ && bar``] &&= 2 < (!1 & {}))) >= 0 * {} % ("number" >> {})) ])]), arguments_2 = (c += 1) + (undefined && undefined[(c += 1) + ~(((2 === [ , 0 ].length) <= 0 ^ !1) >>> !1 / (23..toString() < !1))]), bar = function() {
                var a_2 = function() {
                    c = 1 + c, a_2 = 1 == this, bar && (bar[c = 1 + c, 1] += 2 === [ , 0 ].length | 1), 
                    c = 1 + c, a_2 && (a_2[c = 1 + c, (2 === [ , 0 ].length || 1) === (-0 != this) <= !0] &= 0), 
                    c = 1 + c, bar && ({
                        undefined: bar[c = 1 + c, (bar && (bar.then = "b" < this)) - !1 >> (3 < (null ^ []))]
                    } = {
                        undefined: -2
                    });
                }();
            }((--b, 38..toString(), 38..toString(), c += 1, --b)), b = (c = c + 1 + 1) + (b = a) ? (c += 1) + [ a++ + ("function" == typeof async_2 && 0 <= --_calls_ && async_2()), a++ + a, -2, a++ + (c = 1 + c, 
            0 * (this >> 1 / 0 ^ this === 1 / 0)), void 0 !== undefined & 0 == !0o644n >>> 0, 2 + a++ ][(--b + [ (c = 1 + (c += 1), 
            a_2 && (a_2.value = (c += 1, 38..toString() == 38..toString() | "function"))), (c = 1 + c, 
            (/[a2][^e]+$/ !== this) << !0 ^ (NaN != 24..toString()) * (23..toString() ^ /[a2][^e]+$/)) ] || a || 3).toString()] : a++ + /[abc4]/.test((b + 1 - .1 - .1 - .1 || b || 5).toString()), async_2 = --b + ("function" == typeof bar && 0 <= --_calls_ && bar`\\`);
        }
    } while (--b + (bar && "function" == typeof bar.c && 0 <= --_calls_ && bar.c(..."" + bar)) && 0 < --brake1);
}

var b_2 = f0`${b_2 && b_2.b}`;

console.log(null, a, b, c, 1 / 0, NaN, void 0);
original result:
null 254 10 825 Infinity NaN undefined

uglified result:
null 254 10 836 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
try {
    (function b_1() {})(bar?.[0], ...[ bar?.[0()] ]);
} finally {
    var bar;
}
// output: 
// minify: TypeError: 0 is not a function
// options: {
//   "mangle": false,
//   "module": false,
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
minify(options):
{
  "mangle": false,
  "module": false,
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  pure_getters
  reduce_vars
  spreads
  unused
@alexlamsl alexlamsl added the bug label Jun 20, 2024
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 20, 2024
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 20, 2024
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