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

Closed
alexlamsl opened this issue Aug 13, 2024 · 0 comments · Fixed by #5919
Closed

ufuzz failure #5917

alexlamsl opened this issue Aug 13, 2024 · 0 comments · Fixed by #5919
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0(b_2, bar) {
    function f1(Infinity_2) {}
    var a = f1(--b + -(("foo" > "object" != 3 > "undefined") + ((Infinity != "c") >>> ("bar" || -1))), 4);
    function f2(bar, a_2, undefined_1) {
        {
            L20689: for (var brake6 = 5; a++ + bar && brake6 > 0; --brake6) {
                return c = 1 + c, (c = c + 1, "number" << "object") || (-0 == 5) <= 4 << "foo";
            }
        }
        switch (a++ + delete b) {
          case --b + a++:
            if (--b + (1 === 1 ? a : b)) {
                c = c + 1;
            }
            break;

          default:
            for (var brake11 = 5; (c = c + 1) + 3 && brake11 > 0; --brake11) {
                try {
                    c = 1 + c, (-4 || 23..toString() || 23..toString() == 3) >= ("bar" ^ 5) * (-4 <= -3);
                } finally {
                }
            }

          case a++ + (b = a):
            switch (undefined_1 && typeof undefined_1.next == "function" && --_calls_ >= 0 && undefined_1.next((c = 1 + c, 
            (null < "a" ^ "foo" / /[a2][^e]+$/) + (("b" !== ([ , 0 ].length === 2)) + (NaN == 5))), "")) {
              case b++:
                c = 1 + c, ("function" === "foo") >>> (bar && (bar[c = 1 + c, (false > 2) >> ("bar" >>> undefined) <= ("function" == Infinity | -1 >>> -3)] += ([ , 0 ].length === 2) > 38..toString())) ^ (NaN | "c") & [] <= "foo";
                c = 1 + c, (true > -0) << (-0 && 38..toString()) >= (bar && (bar.done += (24..toString(), 
                Infinity) && 5 - 2));
                break;

              case a++ + [ (c = 1 + c, ({} ^ [ , 0 ].length === 2 || 22 < 22) << ("a" & 0, 
                23..toString() >> this)) ].null:
                c = 1 + c, ("foo" > -2) + (-0 != true) >= ([ , 0 ].length === 2 === 23..toString()) >> 3 / 1;
                break;

              case ((c = 1 + c, ([ , 0 ].length === 2) >= -0 != NaN * "foo", (bar && (bar.next |= true << NaN)) >= ({} >= NaN)) || a || 3).toString():
                c = 1 + c, (bar && (bar[(c = c + 1) + typeof (c = 1 + c, ("function" > -4) % ("function" !== "undefined") < ("bar" <= "" ^ "undefined" != "function"))] &= (a_2 /= "bar" <= -0, 
                false >> false))) << delete (4 ^ 22);
                c = 1 + c, undefined_1 && (undefined_1.get = Infinity >> undefined & [ , 0 ].length === 2 != "undefined" ^ "bar" <= this == (NaN !== []));
                break;

              case /[abc4]/g.exec(((c = 1 + c, ~(("c" ^ []) << "foo" / true)) || b || 5).toString()):
                c = 1 + c, (bar && (bar.in |= (22 ^ NaN) >> ("object" | -2))) > (5 % Infinity <= [] - 22);
                break;
            }
            break;

          case (c = c + 1) + typeof (a++ + /[abc4]/g.exec((bar || b || 5).toString())):
            var Infinity_2;
            break;
        }
        if ((c = c + 1) + b--) {
            return typeof bar_1;
        }
    }
    var await = f2([ , 0 ][1], (b_2 && typeof b_2.foo == "function" && --_calls_ >= 0 && b_2.foo({}) || 3).toString()[(c = c + 1) + -(("foo" || "object") - (0 ^ true) || ("object" & -1) * ("a" << 1))], --b + (b_2 && typeof b_2.null == "function" && --_calls_ >= 0 && ((c = c + 1) + (bar = function yield() {
        {
            var brake1 = 5;
            while ((c = 1 + c, (2 % 5 <= "b" >> 23..toString()) % ((5 != "c") > ([ , 0 ].length === 2 === -2))) && --brake1 > 0) {
                c = 1 + c, "b" - this == -0 * Infinity & false >> "object" <= (c = c + 1, 
                /[a2][^e]+$/);
            }
        }
        switch (c = 1 + c, ("function" == -5 ^ (a = Infinity < 24..toString())) < ("function" < -5) - (yield && (yield.var += Infinity + "bar"))) {
          default:
            ;

          case c = 1 + c, ("number" << [ , 0 ][1]) - (this ^ true) >= (c = c + 1, 
            -4 >= NaN):
            ;
            break;

          case c = 1 + c, 2 + ([ , 0 ].length === 2) == -3 * 38..toString() | 38..toString() / "object" > -24..toString():
            ;
            break;

          case c = 1 + c, ("b" * "object" >> (a && (a[c = 1 + c, ([], [ , 0 ][1]) / + -0 | (yield && (yield.async %= "" & 0) || "number" ^ 3)] = /[a2][^e]+$/ % "a"))) + ([ , 0 ][1] !== -3 ^ (0 || -1)):
            ;
        }
    }), b_2.null)(a++ + (typeof f4 == "function" && --_calls_ >= 0 && f4()), false, 0)));
    function f3(a_2) {}
    var let_2 = f3();
    function f4(a_1) {
        {
            var brake24 = 5;
            L20690: do {
                try {
                    try {
                        switch (c = 1 + c, (-0 != -1) - (NaN >>> "") <= ([ , 0 ][1] !== -0, 
                        NaN > null)) {
                          default:
                            ;

                          case c = 1 + c, a += void ("object" / true) << (false * false << (2 <= 3)):
                            ;
                            break;

                          case c = 1 + c, (+ -4 >= (3 <= 0)) * (-0 % 5 >>> (false || 4)):
                            ;
                            break;

                          case c = 1 + c, ((0 == -1) >>> (c = c + 1, [ , 0 ][1])) * (3 ^ "b" ^ 4 !== "foo"):
                            ;
                            break;
                        }
                    } catch (undefined_1) {
                        c = 1 + c, (1 - Infinity === (-1 ^ 3)) << !(await && (await.a += 25 % ([ , 0 ].length === 2)));
                        c = 1 + c, (/[a2][^e]+$/ | 25 | true << 24..toString()) >> (-3 & 38..toString() || 38..toString() != null);
                        c = 1 + c, let_2 && (let_2[0 === 1 ? a : b] >>>= void (24..toString() & [ , 0 ].length === 2) != ((-5 ^ "object") === ("b" !== [ , 0 ][1])));
                    }
                } finally {
                    c = 1 + c, (a_1 && (a_1[--b + (typeof f1 == "function" && --_calls_ >= 0 && f1("c", Infinity, -5))] <<= ~4 !== (2, 
                    null))) - (3 & false ^ ([ , 0 ].length === 2) < "function");
                    {
                        var brake32 = 5;
                        do {
                            c = 1 + c, (4 || 38..toString()) > "" >>> [ , 0 ][1] === (c = c + 1, 
                            this) / ("foo" >> "undefined");
                        } while ((c = 1 + c, 22 >> 5 || this == null || (bar && (bar[c = 1 + c, 
                        (-2 - 4 === "b" > -3) << (-0 === "number" & -2 > "c")] = 5 < -5)) - (-3 == 2)) && --brake32 > 0);
                    }
                }
            } while ((0, "undefined") && "undefined" == -4 && -3 * 4 > (-5 & 24..toString()) && --brake24 > 0);
        }
    }
    var b_1 = f4("b", "c");
    function f5() {
        function f6(bar) {
            function f7(b, bar, bar) {
            }
            var foo = f7((c = 1 + c, ("foo" > -1 & (-5 ^ {})) < (5 >>> "a" > (-1 ^ {}))));
            function f8(Infinity_2) {
            }
            var a = f8`${c = 1 + c, ("function" <= "c" ^ (let_2 && (let_2.Infinity = "number" >> -3))) * ("foo" << 3 ^ ("a" | 38..toString()))}\``;
            function f9(bar_2, bar) {
            }
            var foo_2 = f9((c = 1 + c, ((bar && (bar[c = 1 + c, (c = c + 1, NaN) >>> (4 == 3) >= /[a2][^e]+$/ << -1 >> (2 != -5)] = "object" % 4)) & "foo" === false) > ((bar && (bar[c = 1 + c, 
            2 >= [ , 0 ][1] == -3 % "c" ^ 24..toString() != -3 != ("number", false)] = 25 ^ undefined)) & +[ , 0 ][1])), ..."" + b_1, 22);
        }
        var foo_2 = f6(2);
        function f10(arguments, a_1) {
            c = 1 + c, (22 ^ true && (-3 || false)) == ((arguments = -5 >= {}) ^ false * "a");
        }
        var foo_1 = f10(24..toString(), /[a2][^e]+$/, -1);
    }
    var c_2 = f5();
}

var yield_1 = f0(yield_1 += (a++ + [ yield_1, +(c = c + 1, 3 >> 23..toString() == ([] == "number")) ][--b + !("number" > "object" > (5 == 0) >= ("b" || 3) / (c = c + 1, 
-5))] || 1).toString()[b--]);

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

function f0(b_2, bar) {
    var a = void --b;
    var await = function(bar, undefined_1) {
        var brake6 = 5;
        if (a++ + bar && 0 < brake6) {
            return c = 1 + c, c += 1, !0;
        }
        switch (a++ + delete b) {
          case --b + a++:
            --b + a && (c += 1);
            break;

          default:
            for (var brake11 = 5; (c += 1) + 3 && 0 < brake11; --brake11) {
                c = 1 + c;
            }

          case a++ + (b = a):
            switch (undefined_1 && "function" == typeof undefined_1.next && 0 <= --_calls_ && undefined_1.next((c = 1 + c, 
            ("b" !== (2 === [ , 0 ].length)) + !1), "")) {
              case b++:
                c = 1 + c, bar && (bar[c = 1 + c, !0] += (2 === [ , 0 ].length) > 38..toString()), 
                c = 1 + c, bar && (bar.done += (24..toString(), 3));
                break;

              case a++ + [ (c = 1 + c, ({} ^ 2 === [ , 0 ].length || !1) << (23..toString() >> this)) ].null:
                c = 1 + c, 23..toString();
                break;

              case c = 1 + c, ((bar && (bar.next |= 1)) >= (NaN <= {}) || a || 3).toString():
                c = 1 + c, bar && (bar[(c += 1) + (c = 1 + c, typeof !0)] &= 0), 
                c = 1 + c, undefined_1 && (undefined_1.get = 0 & 2 === [ , 0 ].length != "undefined" ^ "bar" <= this == (NaN !== []));
                break;

              case /[abc4]/g.exec((c = 1 + c, (~(("c" ^ []) << NaN) || b || 5).toString())):
                c = 1 + c, bar && (bar.in |= 0);
            }
            break;

          case (c += 1) + typeof (a++ + /[abc4]/g.exec((bar || b || 5).toString())):
        }
        return (c += 1) + b-- ? typeof bar_1 : void 0;
    }(0, ((b_2 && "function" == typeof b_2.foo && 0 <= --_calls_ && b_2.foo({}) || 3).toString()[(c += 1) + -0], 
    --b + (b_2 && "function" == typeof b_2.null && 0 <= --_calls_ && (c += 1, b_2.null)(a++ + (0 <= --_calls_ && f4()), !1, 0))));
    var let_2 = void 0;
    function f4(a_1) {
        try {
            try {
                switch (!1) {
                  default:
                  case c = 1 + (c = 1 + c), a += 0:
                    break;

                  case 0, c = 1 + (c = 1 + c), 2 * (!1 >>> (c += 1, 0)):
                }
            } catch (undefined_1) {
                c = 1 + c, await && (await.a += 25 % (2 === [ , 0 ].length)), c = 1 + c, 
                24..toString(), -3 & 38..toString() || 38..toString(), c = 1 + c, 
                let_2 && (let_2[b] >>>= 0 != void 24..toString());
            }
        } finally {
            c = 1 + c, a_1 && (a_1[--b + (0 <= --_calls_ && void 0)] <<= !0);
            for (var brake32 = 5; c = 1 + c, c = 1 + (c += 1), null == this ? 0 < --brake32 : (c = 1 + c, 
            0, !1) - !1; ) {}
        }
    }
    f4("b");
    (function() {
        var bar;
        (function(Infinity_2) {})`${c = 1 + (c = 1 + c), (!(bar = 2) ^ (let_2 && (let_2.Infinity = 0))) * (0 ^ ("a" | 38..toString()))}\``, 
        c = 1 + c, bar && (bar[c = 1 + c, c += 1, !0] = NaN), bar && (bar[c = 1 + c, 
        !1 ^ -3 != 24..toString() != !1] = 25), 24..toString(), c = 1 + c;
    })();
}

var yield_1 = f0(yield_1 += (a++ + [ yield_1, (c += 1, +(3 >> 23..toString() == ("number" == []))) ][--b + !("b" / (c += 1, 
-5) <= !1)] || 1).toString()[b--]);

console.log(null, a, b, c, 1 / 0, NaN, void 0);

export {
    _calls_,
    a,
    b,
    c
};
original result:
null 101 NaN 35 Infinity NaN undefined

uglified result:
null 101 NaN 36 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
function f0(bar) {
    0 && (bar = function yield() {})(f4);
    function f4() {
        bar[0];
    }
    f4();
}

f0();
// output: TypeError: Cannot read property '0' of undefined
// minify: 
// options: {
//   "mangle": false,
//   "module": false,
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
minify(options):
{
  "mangle": false,
  "module": false,
  "output": {
    "v8": true
  }
}

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