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

Closed
alexlamsl opened this issue Jul 29, 2022 · 0 comments · Fixed by #5585
Closed

ufuzz failure #5584

alexlamsl opened this issue Jul 29, 2022 · 0 comments · Fixed by #5585
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0() {
    (c = c + 1) + (--b + (0 === 1 ? a : b) || 7).toString()[a++];
    switch (b /= a) {
      case ((await, await_2, b_2) => (b_1 => {
            var b_2 = {
                foo: --b + !(({} + false) * (undefined === "c") / (22 & 23..toString() | /[a2][^e]+$/ ^ undefined)),
                1.5: /[abc4]/.test((+function b_2() {
                }() || b || 5).toString()),
                "": await && await.get
            }, await = (c = c + 1) + (b + 1 - .1 - .1 - .1);
            var bar_2 = {
                [-0 in {
                    then: (c = 1 + c, (-3 >> ([ , 0 ].length === 2)) - (-0 << {}) && 3 % undefined < (-1 & -2)),
                    next: (c = 1 + c, await && (await[b_1] = ((b_2 && (b_2[c = 1 + c, 
                    {} % 5 % ("" <= "object") >> ("a" + 3) * (-4 >= 23..toString())] = [ , 0 ].length === 2 ^ 3)) & !{}) >> (NaN && (NaN[c = 1 + c, 
                    0 % 22 > (-0 & 25) | (false - 3) % ("undefined" <= this)] = "number" - 23..toString())) - (true != "foo"))),
                    0: (c = 1 + c, (([] | this) >>> "number" + true) * +(b_2 = "b" && -1)),
                    NaN: (c = 1 + c, ((b_1 && (b_1[c = 1 + c, ((this | 25) <= ([ , 0 ].length === 2 == "object")) % ((this === -4) % (/[a2][^e]+$/ >= 5))] = undefined - -5)) >>> (22 << 38..toString())) - ((38..toString(), 
                    [ , 0 ].length === 2) >= ("" !== null)))
                }]: ~((0 || -4) & false != 0 || "b" >= /[a2][^e]+$/ ^ (await && (await.done += "" & [ , 0 ][1]))),
                "": --b + (typeof undefined_2 == "symbol"),
                3: {
                    "-2": (c = 1 + c, await_2 && (await_2.a += "" << ([ , 0 ].length === 2) >>> (null ^ "foo") && (Infinity ^ 5) & -0 == [ , 0 ][1])),
                    [(c = 1 + c, (true * [] > (c = c + 1, -1)) - ((b_1 && (b_1[c = 1 + c, 
                    ("undefined" == "b") >>> (NaN = [ , 0 ][1] == 2) >> (b_2 && (b_2[{
                        async: (c = 1 + c, ("" % "bar" & 1 - 2) / (("" === 22) / (-0 !== this))),
                        "\t": (c = 1 + c, ("" == "a") * ({} <= -1) % ((1 | "bar") % (-2 | {}))),
                        3: (c = 1 + c, c = c + 1, ("" >> -2) - (true >> "foo")),
                        get: (c = 1 + c, await && (await.NaN += 3 * 0 / ("c" == true) === (-3 || -1) > (-2 < "number"))),
                        length: (c = 1 + c, (38..toString() - /[a2][^e]+$/ ^ ([ , 0 ][1] ^ 22)) % ("" / 24..toString() << ("c" ^ 4)))
                    }.set] = -4 + 5 <= void true))] = this & null)) >= void "function"))]: (c = 1 + c, 
                    (5 > "b") - "bar" % "a" & "b" !== 25 !== (NaN && (NaN[c = 1 + c, 
                    this === 2 & (this, "bar"), 23..toString() > this === 2 - 4] /= 25 % 24..toString()))),
                    a: (c = 1 + c, (-1 ^ "bar" && true === -3) < (5 === "function") >> "" * [ , 0 ][1]),
                    set: (c = 1 + c, (await = (0 ^ 38..toString()) & (2 ^ "c")) >= (/[a2][^e]+$/ === -5) >> [] - -2)
                }
            }[a++], NaN = (c = c + 1) + function b_2_1() {};
        })())(a++ + [ --b + [ /[abc4]/g.exec((5 % "foo" + (24..toString() ^ 23..toString()) << (undefined % false || null <= "object") || b || 5).toString()) ] ][a++ + (typeof NaN_2 === "crap")], "b"):
        break;

      case (c = c + 1) + (a && a[a++ + (a && typeof a.a == "function" && --_calls_ >= 0 && a.a())]):
        return a++ + [ +function() {
            switch (a++ + (c = 1 + c, (-4 !== true) + "a" % /[a2][^e]+$/ | "number" + undefined + (true < -4))) {
              case --b + (a && typeof a.null == "function" && --_calls_ >= 0 && a.null(-1)):
                break;

              case a:
                c = 1 + c, 5 << this < ("number" !== "bar") | 3 >>> "function" << ("undefined" ^ [ , 0 ].length === 2);
                c = 1 + c, (a <<= null / undefined) - (c = c + 1, "function") > NaN + "foo" - (-5 - 24..toString());
                break;

              case delete ((5 <= {} != "function" >> 24..toString()) >= (-1 >= -0 >= 0 >>> 1)):
                c = 1 + c, a && (a[b = a] += (a += "" / 4 + ("a" + 25)) >>> (-0 / "a" <= NaN << -5));
                break;

              case {}.value:
                break;
            }
            try {
                {
                    var brake11 = 5;
                    do {
                        c = 1 + c, "number" === "bar" != (a += "" !== ([ , 0 ].length === 2)) && 24..toString() << [] ^ (/[a2][^e]+$/ | "");
                    } while ((c = 1 + c, (a && ({
                        1.5: a.next
                    } = {
                        1.5: (-3 ^ -4) <= (3 ^ -1)
                    })) ^ (a && (a[(c = 1 + c, ("" ^ "a", -4 < "undefined") << (([ , 0 ].length === 2 && -0) == 4 / [])) ? (c = 1 + c, 
                    (c = c + 1, 0 % 38..toString()) + ((3 | -3) << /[a2][^e]+$/ - -4)) : (c = 1 + c, 
                    delete (/[a2][^e]+$/ !== [ , 0 ][1]) !== [] >= "undefined" >= /[a2][^e]+$/ / "")] = ("number" <= "c") >>> [] / -3))) && --brake11 > 0);
                }
            } catch (bar) {
                c = 1 + c, "a" >> "c" >>> (NaN >= true) & false == 25 != (-2, 22);
                c = 1 + c, bar && (bar[b <<= a] %= ("function" - 38..toString() != 2 >> undefined) >= "b" * "c" + (NaN >> -3));
            }
        }(), (c = c + 1) + (--b + {
            length: --b + !((-1 & 38..toString()) != (NaN & -0) ^ (25 | -3 && "foo" | true)),
            value: typeof f2 == "function" && --_calls_ >= 0 && f2(),
            next: (c = c + 1) + 24..toString(),
            1.5: {
                ...a,
                value: (c = 1 + c, (NaN - -1 ^ 25 != 25) > (25 <= -1 > ("function" == /[a2][^e]+$/))),
                length: (c = 1 + c, ("" > 0) << (Infinity ^ 22) || null / -0 ^ "foo" > Infinity),
                done: (c = 1 + c, ("b" ^ "") == (null && -1) | (/[a2][^e]+$/ == true) % ("" | /[a2][^e]+$/)),
                in: (c = 1 + c, a = (null ^ Infinity) - ("function" == "number") | (false & "c") === 5 >> "a")
            }[c = 1 + c, (a && (a.var >>>= -0 + 2 > ("object" === 38..toString()))) >= ([] === -0 && (false || /[a2][^e]+$/))]
        } ? a++ + NaN : (c = c + 1) + {}), -0, --b + (a && typeof a.static == "function" && --_calls_ >= 0 && (--b + (typeof f2 == "function" && --_calls_ >= 0 && f2() || a || 3).toString(), 
        a.static)`tmpl${void setImmediate(() => a && typeof a.null == "function" && --_calls_ >= 0 && a.null(0, (c = 1 + c, 
        ("number" >= 4 && null >> false) == (22 << 0 ^ (3 | [])))))}${typeof a == "function" && --_calls_ >= 0 && a`${c = 1 + c, 
        +((false || 23..toString()) >> +24..toString())}${c = 1 + c, (a && (a.__proto__ += (25 && 24..toString()) < (25, 
        []))) - (c = c + 1, a && (a.value = -4 >= 1))}${c = 1 + c, (true != -4) / (a && (a[c = 1 + c, 
        (4 | NaN | (-5 && -3)) >> (a %= (c = c + 1, 4) >= ({} | null))] += "" !== Infinity)) * ((a && (a.foo += ("bar", 
        "c"))) < (-0 | Infinity))}`}${typeof a == "function" && --_calls_ >= 0 && a((c = 1 + c, 
        (a += "function" || {}) >>> (true && "c") | ("undefined" == "") << (/[a2][^e]+$/ != 23..toString())))}`), b-- ][--b + (typeof f1 == "function" && --_calls_ >= 0 && f1(typeof a == "function" && --_calls_ >= 0 && a(--b + (b += a)), a++ + (a && a.a), 3))];
        {
            var brake15 = 5;
            while ((--b + --b || a || 3).toString() && --brake15 > 0) {
                var expr16 = +b;
                for (var key16 in expr16) {
                    c = 1 + c;
                    var let_1 = expr16[key16];
                    var b_2;
                }
            }
        }
        break;

      default:
      case (c = c + 1) + a++:
        {
            {
                var brake19 = 5;
                while (--b + (typeof f2 == "function" && --_calls_ >= 0 && f2`\\${c = 1 + c, 
                ("a" > -3) / (NaN + true) != (a && (a.undefined = 23..toString() != "c" || false == "object"))}${a++ + this}`) && --brake19 > 0) {
                    {
                        var foo = function f1(c_1, let_1) {
                        }(0, [ , 0 ][1]);
                    }
                    {
                        return foo && typeof foo.in == "function" && --_calls_ >= 0 && foo.in("object");
                    }
                    {
                        var brake23 = 5;
                        while (/[abc4]/.test(((c = 1 + c, +23..toString() + (NaN > "undefined") >> (-3 / -2 < "function" * "object")) || b || 5).toString()) && --brake23 > 0) {
                            switch (c = 1 + c, ((NaN, {}) == ("number" ^ -2)) - (NaN >>> "" != ("a" === ""))) {
                              case c = 1 + c, +("" && -5) ^ (c = c + 1, undefined) >>> (24..toString() != 22):
                                ;
                                break;

                              case c = 1 + c, ((foo = -5 + []) & false >= 3) < (0 << 3 ^ [ , 0 ][1] != 23..toString()):
                                ;
                                break;

                              case c = 1 + c, 24..toString() >= 22 >= void true | + -1 >= (NaN == "number"):
                                ;
                                break;

                              case c = 1 + c, (foo && (foo.then -= 1 !== "b")) % ("undefined" + "number") | {} + "b" >>> (Infinity << 38..toString()):
                                ;
                                break;
                            }
                        }
                    }
                }
            }
            {
                return a++ + ++a;
            }
            try {
            } catch (arguments_1) {
                var b_2 = (c = c + 1) + (a++ || 5).toString()[arguments_1], bar_1 = --b + (b >>>= a);
                a++ + (arguments_1 = --b + !function() {
                }());
            }
        }
    }
}

var a_2 = f0(--b + /[abc4]/g.exec((--b + (typeof a == "function" && --_calls_ >= 0 && a([])) || b || 5).toString()), "function");

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

function f0() {
    switch (c += 1, --b, b /= ++a) {
      case a++, --b, a++, t = {
            foo: --b + !0,
            1.5: /[abc4]/.test((b || 5).toString()),
            "": n && n.get
        }, n = (c += 1) + (b + 1 - .3), c = 1 + (c = 1 + c), n && (n[void 0] = (!1 & (t && (t[c = 1 + c, 
        0] = 2 === [ , 0 ].length ^ 3))) >> (e && (e[c = 1 + c, !1 | -3 % ("undefined" <= this)] = NaN)) - !0), 
        t = -1, c = 1 + (c = 1 + c), n && (n.done += 0), --b, c = 1 + (c = 1 + c), 
        c = 1 + (c += 1), e && (e[c = 1 + c, this < "23" === -2] /= 1), c = 1 + (c = 1 + c), 
        n = 2, a++, void (e = (c += 1) + function() {}):
        break;

      case (c += 1) + (a && a[a++ + (a && "function" == typeof a.a && 0 <= --_calls_ && a.a())]):
        return a++ + [ +function() {
            switch (a++ + (c = 1 + c, 0)) {
              case --b + (a && "function" == typeof a.null && 0 <= --_calls_ && a.null(-1)):
                break;

              case a:
                c = 1 + (c = 1 + c), a <<= NaN, c += 1;
                break;

              case !0:
                c = 1 + c, a && (a[b = a] += (a += "0a25") >>> !1);
            }
            try {
                for (var t = 5; c = 1 + (c = 1 + c), ((a += "" !== (2 === [ , 0 ].length)) && ({
                    1.5: a.next
                } = {
                    1.5: !1
                })) ^ (a && (a[c = 1 + c, !1 << ((2 === [ , 0 ].length && -0) == 1 / 0) ? (c = 1 + c, 
                c += 1, -1) : (c = 1 + c, !0)] = 0)) && 0 < --t; ) {}
            } catch (t) {
                c = 1 + (c = 1 + c), t && (t[b <<= a] %= !1);
            }
        }(), (c += 1) + (--b + {
            length: --b + !0,
            value: "function" == typeof f2 && 0 <= --_calls_ && f2(),
            next: (c += 1) + "24",
            1.5: {
                ...a,
                value: !1,
                length: 0,
                done: 0,
                in: (c = 1 + (c = 1 + (c = 1 + (c = 1 + c))), a = 0)
            }[c = 1 + c, !1 <= (a && (a.var >>>= !0))]
        } ? a++ + NaN : (c += 1) + {}), -0, --b + (a && "function" == typeof a.static && 0 <= --_calls_ && (--b, 
        ("function" == typeof f2 && 0 <= --_calls_ && f2() || a || 3).toString(), 
        a.static)`tmpl${void setImmediate(() => a && "function" == typeof a.null && 0 <= --_calls_ && a.null(0, (c = 1 + c, 
        !1)))}${"function" == typeof a && 0 <= --_calls_ && a`${c = 1 + c, 0}${c = 1 + c, 
        (a && (a.__proto__ += !1)) - (c += 1, a && (a.value = !1))}${c = 1 + c, 
        !0 / (a && (a[c = 1 + c, -3 >> (a %= (c += 1, !0))] += !0)) * ((a && (a.foo += "c")) < 0)}`}${"function" == typeof a && 0 <= --_calls_ && a((c = 1 + c, 
        (a += "function") >>> "c" | 0))}`), b-- ][--b + ("function" == typeof f1 && 0 <= --_calls_ && f1("function" == typeof a && 0 <= --_calls_ && a(--b + (b += a)), a++ + (a && a.a), 3))];

      default:
      case (c += 1) + a++:
        return --b, "function" == typeof f2 && 0 <= --_calls_ && f2`\\${c = 1 + c, 
        NaN != (a && (a.undefined = !0))}${a++ + this}`, a++ + ++a;
    }
    var t, n, e;
}

var a_2 = f0(--b + /[abc4]/g.exec((--b + ("function" == typeof a && 0 <= --_calls_ && a([])) || b || 5).toString()), "function");

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

uglified result:
null 108 -3.9306930693069306 16 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
var a = 0, c;

function f0() {
    switch (0) {
      case c:
      case a:
        var brake19 = 0;
        while (--brake19) {
            var foo;
            return foo;
        }
        return ++a;
    }
}

f0();

console.log(a);
// output: 0
// 
// minify: 1
// 
// options: {
//   "compress": {
//     "passes": 1000000,
//     "sequences": 1000000,
//     "unsafe": true,
//     "unsafe_Function": true,
//     "unsafe_math": true,
//     "unsafe_proto": true,
//     "unsafe_regexp": true
//   },
//   "mangle": {
//     "v8": 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
  },
  "mangle": {
    "v8": true
  },
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  dead_code
  evaluate
  if_return
  loops
  passes
  reduce_vars
@alexlamsl alexlamsl added the bug label Jul 29, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jul 29, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jul 30, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jul 30, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jul 30, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jul 30, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jul 30, 2022
alexlamsl added a commit that referenced this issue Jul 30, 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