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

Closed
alexlamsl opened this issue Oct 4, 2022 · 0 comments · Fixed by #5698
Closed

ufuzz failure #5697

alexlamsl opened this issue Oct 4, 2022 · 0 comments · Fixed by #5698
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0(async) {
    function f1(arguments) {
        function f2(foo_1, c_2) {
            {
            }
            if (c = 1 + c, (-4 & [ , 0 ].length === 2) < [] << 2 ^ (25, 2) * (4, 
            "b")) {
                c = 1 + c, ("a" | -5) % (24..toString() >= -0) % ((1 >= {}) >> ("" ^ 4));
            } else {
                c = 1 + c, ([] > Infinity) - ("c" >= this) ^ (c = c + 1, undefined, 
                "function", {});
            }
            c = 1 + c, "foo" < 0 == -3 / Infinity ^ !3 < ("object" ^ []);
        }
        var a_2 = f2((23..toString() & /[a2][^e]+$/) + (-3 && "number") || ({} ^ 23..toString() || (c = c + 1, 
        "number")), ("function" + undefined >= 2 << 1) - ("foo" >> this & 23..toString() === -0), typeof f4 == "function" && --_calls_ >= 0 && f4((c = 1 + c, 
        (("foo" !== -1) << (-4 && [ , 0 ][1])) * ((async && (async.b += [] >> "c")) | 4 > -4))));
        function f3() {
            switch (c = 1 + c, "number" << 5 << (false | [ , 0 ][1]) === (arguments && (arguments.done = (c = c + 1, 
            23..toString()) ^ (null && "a")))) {
              case c = 1 + c, arguments && (arguments[(c = c + 1) + (0 === 1 ? a : b)] += (22 == [] === (arguments && (arguments[c = 1 + c, 
                (async && (async.static >>>= /[a2][^e]+$/ || false)) !== ("undefined" !== 4) == 2 - "object" > -3 - {}] -= null || 22))) >> ("foo" && "b" && (false || "object"))):
                ;
                break;

              case c = 1 + c, ("a" % 5 ^ (-3 | "b")) + ((async && (async[c = 1 + c, 
                ("function" == false) >= ("undefined" ^ "b") ^ 3 + "a" >= {} >> "b"] += -3 == 1)) & (-4 || 2)):
                ;

              default:
                ;

              case c = 1 + c, ("foo" && this) * (38..toString() < true) % ((-0 !== 3) << (/[a2][^e]+$/ ^ "a")):
                ;
                break;
            }
        }
        var bar_1 = f3("object", (c = c + 1) + {
            undefined: (c = 1 + c, ((c = c + 1, "a") == (undefined & "undefined")) > (arguments && (arguments[{
                set: (c = 1 + c, !(-"a" && undefined << -0)),
                static: (c = 1 + c, (async && (async[a++ + [ (c = 1 + c, ~((/[a2][^e]+$/ | undefined) == 1 >> 38..toString())) ][c = 1 + c, 
                ("bar" >= false & (arguments && (arguments[c = 1 + c, ("number" || "function" || -3 | 1) >= (-2 <= -3 == -4 >= -3)] += "number" % "a"))) >= (arguments && (arguments.value -= 5 | []) && Infinity != -0)]] = Infinity < "a" != "number" > undefined)) + ((-3 === 3) << false * Infinity)),
                Infinity: (c = 1 + c, (-4 >> 23..toString() >= undefined * (-42n).toString()) + (("number" == 22) + ([ , 0 ].length === 2) % 24..toString()))
            }.in] = (0 >> 4) / (Infinity >>> "a"))))
        }[{
            3: (c = 1 + c, a_2 && (a_2[a--] = (/[a2][^e]+$/ < -0 ^ undefined << Infinity) < ("a" != -2 == (a_2 && (a_2[c = 1 + c, 
            ~(3 << 4 << ("undefined" === 38..toString()))] = 1 && 5)))))
        }.length]);
    }
    var await_1 = f1((c = c + 1) + (typeof f5 == "function" && --_calls_ >= 0 && f5(this)));
    function f4(await_2) {
        {
            var let_2 = function f5(foo = NaN) {
                L23432: for (var brake8 = 5; (c = 1 + c, (false % NaN == /[a2][^e]+$/ - "b") + +(NaN / {})) && brake8 > 0; --brake8) {
                    c = 1 + c, (await_2 && (await_2[c = 1 + c, ((async && (async[c = 1 + c, 
                    (await_1 && (await_1[c = 1 + c, (foo = 5 - undefined >= 24..toString() + "") !== ("" ^ "bar") * (-3 ^ "number")] += "" << 24..toString()) && ("undefined", 
                    24..toString())) * ("b" === "b" && 25 > 5)] = NaN == "b")) == ([ 3n ][0] > 2) >> 2) / ("" >> /[a2][^e]+$/ ^ (null || [ , 0 ].length === 2))] += 38..toString() / "number")) + (await_2 += 38..toString() != /[a2][^e]+$/) - (0 / 0, 
                    await_2 = -2 ^ "function");
                }
                var arguments_1;
                {
                    var expr11 = (c = 1 + c, c = c + 1, -5 != undefined | [] & 22);
                    for (var key11 in expr11) {
                        c = 1 + c;
                        const async = expr11[key11];
                        c = 1 + c, (async && (async.done |= (c = c + 1, "") ^ 25 != 22)) ^ void "function" != 23..toString() - /[a2][^e]+$/;
                    }
                }
            }(23..toString());
        }
    }
}

var yield = f0([ a--, !(("foo" <= []) - ("bar" || [])), --b + a ]);

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

function f0(n) {
    !function(arguments) {
        if (0 <= --_calls_) {
            for (var n in c = 1 + c, e && (e.b += 0), c = 1 + (c = 1 + c), c += 1, 
            1) {
                c = 1 + c;
                var e = 1[n];
                c = 1 + c, e && (e.done |= !0 ^ (c += 1, ""));
            }
        }
        c = 1 + c, (-4 & 2 === [ , 0 ].length) < 0 ^ NaN ? c = 1 + c : (c = 1 + c, 
        c += 1);
        var t = void (c = 1 + c);
        !function() {
            switch (c = 1 + c, 0 === (arguments && (arguments.done = null ^ (c += 1, 
            "23")))) {
              case c = 1 + c, arguments && (arguments[(c += 1) + b] += (!1 === (arguments && (arguments[c = 1 + c, 
                !0 !== (e && (e.static >>>= /[a2][^e]+$/)) == 0] -= 22))) >> "object"):
                break;

              case c = 1 + c, (-4 & (e && (e[c = 1 + c, 1] += !1))) - 3:
              default:
              case c = 1 + c, !1 * this % 1:
            }
        }("object", (c += 1) + {
            undefined: (c = 1 + c, (0 == (c += 1, "a")) > (arguments && (arguments[{
                set: !0,
                static: (c = 1 + (c = 1 + c), (e && (e[a++ + [ -2 ][c = 1 + (c = 1 + c), 
                (!1 & (arguments && (arguments[c = 1 + c, !1] += NaN))) >= (arguments && (arguments.value -= 5) && !0)]] = !1)) + 0),
                Infinity: (c = 1 + c, !1 + (2 === [ , 0 ].length) % "24" + (void 0 * ("" + -42n) <= -1))
            }.in] = NaN)))
        }[{
            3: (c = 1 + c, t && (t[a--] = 0 < (1 == (t && (t[c = 1 + c, -49] = 5)))))
        }.length]);
    }((c += 1) + ("function" == typeof f5 && 0 <= --_calls_ && f5(this)));
}

var yield = f0([ a--, !0, --b + a ]);

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

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

// (beautified)
function f0() {
    var a_2 = f4 && f4();
    async;
    function f4() {
        var let_2 = function f5() {
            for (var brake8 = 5; 0; 0) {
                async;
            }
            for (var key11 in 0) {
                const async = key11;
                async && async.done;
            }
        }();
    }
}

f0();
// output: ReferenceError: async is not defined
// 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:
  conditionals
  dead_code
  evaluate
  inline
  loops
  passes
  reduce_funcs
  reduce_vars
  sequences
  side_effects
  unsafe
  unused
  varify
@alexlamsl alexlamsl added the bug label Oct 4, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Oct 4, 2022
alexlamsl added a commit that referenced this issue Oct 4, 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