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

Closed
alexlamsl opened this issue Oct 14, 2022 · 0 comments · Fixed by #5713
Closed

ufuzz failure #5712

alexlamsl opened this issue Oct 14, 2022 · 0 comments · Fixed by #5713
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

for (var brake1 = 5; a++ + (typeof f0 == "function" && --_calls_ >= 0 && f0()) && brake1 > 0; --brake1) {
    switch (typeof f0 == "function" && --_calls_ >= 0 && f0(a--, ..."" + a, "")) {
      case --b + +a:
        a++ + (0 === 1 ? a : b);
        if (a++ + (a && typeof a.get == "function" && --_calls_ >= 0 && a.get())) {
            try {
                c = c + 1;
            } catch (await) {} finally {
                c = c + 1;
                L38962: {
                    {
                        var brake10 = 5;
                        do {
                            (c = c + 1) + (typeof f0 == "function" && --_calls_ >= 0 && f0((c = 1 + c, 
                            undefined >= 38..toString() <= (-1 === "undefined") >= (false % 0 ^ 5 >>> undefined))));
                        } while ({
                            __proto__: (c = 1 + c, (3 | [ , 0 ].length === 2) / (a %= -1 % []) || "foo" >> 4 !== (2 || "a")) || {}
                        }[[ (c = 1 + c, [ , 0 ][1] + 0 - (null === -4) != (a && (a.foo = 24..toString() & 24..toString() | (/[a2][^e]+$/ && "foo")))) ][c = 1 + c, 
                        ((NaN == "undefined") + (a && (a[c = 1 + c, -3 / "b" * (-0 + 2) ^ +delete "bar"] = "a" || false))) ** ((this | "bar") === "" >> /[a2][^e]+$/)]] && --brake10 > 0);
                    }
                    c = c + 1;
                    {
                        var undefined_1 = function NaN(foo_2, undefined_1) {}((c = 1 + c, 
                        undefined_1 && (undefined_1[a++ + b--] = (c = c + 1, -5 - -0) && -0 - false === (-4 != 38..toString()))));
                    }
                    {
                        var brake14 = 5;
                        L38963: do {
                            {
                                var brake15 = 5;
                                while (--b + (typeof f1 == "function" && --_calls_ >= 0 && f1`${c = 1 + c, 
                                (undefined >> "function" ^ Infinity > 24..toString()) % ([] / ([ , 0 ].length === 2) ^ Infinity != 2)}} `) && --brake15 > 0) {
                                    var brake16 = 5;
                                    while ((c = 1 + c, (-2 == "number" == (undefined_1 += -4 % ([ , 0 ].length === 2))) << (true - "", 
                                    c = c + 1, false)) && --brake16 > 0) {
                                        c = 1 + c, undefined / "number" & (-3) ** -3, 
                                        undefined_1 && (undefined_1[--b + (c = 1 + c, 
                                        (undefined_1 && ({
                                            value: undefined_1.get
                                        } = {
                                            value: "" - /[a2][^e]+$/
                                        })) >>> ("undefined" && [ , 0 ][1]) > ((c = c + 1, 
                                        /[a2][^e]+$/) <= ("b" && "number")))] += (undefined_1 && (undefined_1.undefined = [] >= 2)) > (true >= -2));
                                    }
                                }
                            }
                        } while ((c = c + 1) + (typeof undefined_1 == "function" && --_calls_ >= 0 && undefined_1((c = 1 + c, 
                        true / 23..toString() >>> (-3 || undefined) > void (5 % false)), (c = 1 + c, 
                        (undefined_1 && (undefined_1[((c = 1 + c, ("function" + "b" < (0 || [ , 0 ][1])) / (-5 > -4 === -0 % 38..toString())) || a || 3).toString()] -= 5 % 23..toString() <= (24..toString() == null))) !== (38..toString() > ([ , 0 ].length === 2)) >> (undefined_1 && (undefined_1.undefined <<= -5 ^ 5))), (c = 1 + c, 
                        undefined_1 && (undefined_1.get += (("object" ^ 5) & "a" >= 3) == ([ , 0 ][1] < 22 != 24..toString() >> /[a2][^e]+$/))))) && --brake14 > 0);
                    }
                    try {
                        try {
                        } catch (bar_2) {
                            c = 1 + c, (c = c + 1, 4 == 25) << (undefined_1 && ({
                                done: undefined_1.NaN
                            } = {
                                done: (-5 - "c") ** (bar_2 && (bar_2.null += "b" > false))
                            }));
                            c = 1 + c, (-3 >>> -5 && this / 1) !== (c = c + 1, -3 << true);
                        } finally {
                            c = 1 + c, (-4 << this > 38..toString() >> []) >> ((2, 
                            "object") > ("function" ^ 0));
                            c = 1 + c, ((undefined_1 && (undefined_1[c = 1 + c, 
                            (null | [ , 0 ].length === 2) & (undefined_1 -= 25 ^ [ , 0 ][1]) ^ (-0 || 25) >> ([ , 0 ][1] ^ 5)] = 2 % ([ 3n ][0] > 2))) ^ {} + 5) + ("c" >= "c" <= ("" !== "bar"));
                            c = 1 + c, (undefined_1 && (undefined_1[typeof f1 == "function" && --_calls_ >= 0 && f1((c = 1 + c, 
                            ("b" !== -2) <= delete "foo" ^ (("number" || Infinity) ^ (undefined_1 && ({
                                var: undefined_1.get
                            } = {
                                var: /[a2][^e]+$/ << -4
                            })))))] |= undefined == 0 | (undefined_1 && (undefined_1[c = 1 + c, 
                            [ , 0 ][1] > "object" !== true % "" ^ {} >> "" !== (undefined_1 && (undefined_1[c = 1 + c, 
                            (-0 ^ null) + (undefined_1 && (undefined_1.b = -2 | this)), 
                            false - undefined <= ("number" === "b")] = undefined != "foo"))] *= "" == "function")))) >>> ((-3 & -5) !== 25 >= 23..toString());
                            c = 1 + c, ((-4 && "undefined") <= -1 % "") >>> (/[a2][^e]+$/ * "c" == ([ , 0 ][1] === 3));
                        }
                    } finally {
                        for (var brake27 = 5; (c = 1 + c, (undefined_1 && (undefined_1.set += "bar" > NaN)) * ("object" + "c"), 
                        (undefined_1 && (undefined_1.in = 2 - true)) >> + -1) && brake27 > 0; --brake27) {
                            c = 1 + c, (25 && "a") - (undefined_1 && (undefined_1.a += 2 <= Infinity)) ^ 5 >= 4 >= (25 > -4);
                        }
                        var arguments = (c = 1 + c, 24..toString() + "number" ^ 5 >= null || (undefined_1 && (undefined_1[c = 1 + c, 
                        undefined_1 && (undefined_1[1 === 1 ? a : b] = (-4 % -1 != (25 != [])) - (("a" > -3) + (undefined_1 += [ 3n ][0] > 2 !== 1)))] *= 2 > Infinity)) < ("c" === ""));
                    }
                }
            }
        } else {
            var expr30 = (c = c + 1) + (typeof f1 == "function" && --_calls_ >= 0 && f1(-2));
            for (var key30 in expr30) {
                c = 1 + c;
                var async_1 = expr30[key30];
                L38964: for (var brake31 = 5; {
                    static: 1 === 1 ? a : b,
                    get: typeof f1 == "function" && --_calls_ >= 0 && f1(...[ ..."" + key30, (c = 1 + c, 
                    ((-5 | 25) !== this >>> 3) < ("undefined" >>> 4 && !22)) ]),
                    "\t": --b + (c = c + 1, [ , 0 ][1] / "function" + ("bar" <= 22))
                } && brake31 > 0; --brake31) {
                    var expr32 = a++ + void function undefined() {
                        {
                            var undefined_1 = function undefined(undefined_1, arguments) {
                            }(true, (c = 1 + c, ((-4 ^ /[a2][^e]+$/) <= ({} < "c")) / (22 <= 23..toString() >= [] * "bar")));
                        }
                    }();
                    for (let key32 in expr32) {
                        c = 1 + c;
                        var b_2 = expr32[key32];
                        var arguments_1 = +((b_2 && (b_2.Infinity = (async_1 && ([ async_1[c = 1 + c, 
                        (void 0 ^ null - 2) > ((5, Infinity) & (NaN | "foo"))] ] = [ "number" >> {} ])) == "a" / 0)) % (-0 || this || NaN ^ undefined));
                    }
                }
            }
        }
        {
            var brake35 = 5;
            while ((c = c + 1) + {
                c: void (a && (a.next *= (2 - -1) ** (23..toString() === -2) == (void "object" ^ NaN != false))),
                1.5: (c = c + 1) + (b |= a),
                a: a,
                [({
                    a: a
                }.set || 6).toString()[(c = c + 1) + typeof void a]]: {
                    "": --b
                },
                NaN: a && a[--b + ~(((a && (a.static = 24..toString() || [ , 0 ].length === 2)) + (-4 >>> NaN)) % ([ , 0 ].length === 2 === "c" & 25 >> undefined))]
            }[(c = c + 1) + (typeof (true in [ a++ + (-5 in [ (c = 1 + c, ((a && (a.in += /[a2][^e]+$/ && 22)) != (this | NaN)) - (/[a2][^e]+$/ ^ {} ^ (a = 0 > "a"))) ]), [ (c = 1 + c, 
            (2 > [ , 0 ][1] != null / 25) >= !(1 / "")) ].c ]) || 9).toString()[(c = c + 1) + (b = a)]] && --brake35 > 0) {
                if ({}) {
                    c = c + 1;
                }
            }
        }
        break;

      case --b + 4:
        break;

      default:
        ;

      case a++ + this:
        break;
    }
}

if (0 === 1 ? a : b) {
    var expr40 = --b + typeof (a++ + (23..toString() - 23..toString() == this / "function", 
    (5, 5) >> (c = c + 1, 25)));
    for (var key40 in expr40) {
        continue;
    }
} else if (a++ + /[abc4]/g.exec(((c = c + 1) + (a && a[--b + a--]) || b || 5).toString())) {
    var b;
    b && b[/[abc4]/g.exec((a++ + new function foo(undefined, yield, async_2) {
        this[--b + [][a++ + [ (c = 1 + c, (undefined && (undefined[(c = c + 1) + ~((yield /= (this, 
        1)) * (NaN <= "bar") && (22, -1) == (async_2 && (async_2[c = 1 + c, ~-1 >> 38..toString() + [] >>> ([ , 0 ][1] - "bar" == (5 === undefined))] = "foo" !== 1)))] = !"object" + [ , 0 ][1] % null)) % (async_2 && (async_2.var += "function" ^ 2 || -0 + {}))), (c = 1 + c, 
        -(/[a2][^e]+$/ % 4 == (c = c + 1, "function"))), (c = 1 + c, ("c" & {}) + (23..toString() < 24..toString()) || ("undefined" < "c") % ("undefined" >= -4)) ].b]] /= (("a" ^ "function") & "bar" + 23..toString(), 
        ("number" ^ 38..toString()) !== ("c" | "object")) * ((-5 === null, 24..toString() ^ 4) + (yield = (false && "undefined") != null / "number"));
    }("c") || b || 5).toString())];
}

console.log(null, a, b, c, Infinity, NaN, undefined);
// uglified code
// (beautified)
for (var n, t, f, e, o, i, a, r, c, l, u, y, g, d, h = 10, s = 100, N = 10, p = 0, v = 5; s++ + ("function" == typeof f0 && 0 <= --h && f0()) && 0 < v; --v) {
    switch ("function" == typeof f0 && 0 <= --h && f0(s--, ..."" + s, "")) {
      case --N + +s:
        if (s++, s++ + (s && "function" == typeof s.get && 0 <= --h && s.get())) {
            try {
                p += 1;
            } catch (n) {} finally {
                for (p += 1, n = 5; p += 1, "function" == typeof f0 && 0 <= --h && f0((p = 1 + p, 
                !1)), {
                    __proto__: (p = 1 + p, (3 | 2 === [ , 0 ].length) / (s %= NaN) || !0)
                }[[ (p = 1 + p, 0 != (s && (s.foo = 24))) ][p = 1 + p, (!1 + (s && (s[p = 1 + p, 
                1] = "a"))) ** (0 == ("bar" | this))]] && 0 < --n; ) {}
                p = 1 + (p + 1), t = void (t && (t[s++ + N--] = (p += 1, !1))), 
                f = 5;
                do {
                    for (e = 5; --N + ("function" == typeof f1 && 0 <= --h && f1`${p = 1 + p, 
                    1 % ([] / (2 === [ , 0 ].length) ^ !0)}} `) && 0 < --e; ) {
                        for (o = 5; p = 1 + p, (0 == (t += -4 % (2 === [ , 0 ].length))) << (p += 1, 
                        !1) && 0 < --o; ) {
                            p = 1 + p, t && (t[--N + (p = 1 + p, (t && ({
                                value: t.get
                            } = {
                                value: NaN
                            })) >>> 0 > (p += 1, !0))] += !0 < (t && (t.undefined = !1)));
                        }
                    }
                } while ((p += 1) + ("function" == typeof t && 0 <= --h && t(!1, (p = 1 + (1 + p), 
                (t && (t[p = 1 + p, (s || 3).toString()] -= !1)) !== ((2 === [ , 0 ].length) < "38") >> (t && (t.undefined <<= -2))), (p = 1 + p, 
                t && (t.get += !1)))) && 0 < --f);
                try {
                    p = 1 + (p = 1 + p), t && (t[p = 1 + p, (null | 2 === [ , 0 ].length) & (t -= 25) ^ 0] = 2 % (2 < 3n)), 
                    p = 1 + p, t && (t["function" == typeof f1 && 0 <= --h && f1((p = 1 + p, 
                    "number" ^ (t && ({
                        var: t.get
                    } = {
                        var: 0
                    })) ^ !0))] |= !1 | (t && (t[p = 1 + p, !0 ^ 0 !== (t && (t[p = 1 + p, 
                    t && (t.b = -2 | this), !1] = !0))] *= !1))), p = 1 + p;
                } finally {
                    for (i = 5; p = 1 + p, t && (t.set += !1), (t && (t.in = 1)) >> -1 && 0 < i; --i) {
                        p = 1 + p, t && (t.a += !0);
                    }
                    p = 1 + p;
                }
            }
        } else {
            for (r in a = (p += 1) + ("function" == typeof f1 && 0 <= --h && f1(-2))) {
                for (p = 1 + p, c = a[r], l = 5; "function" == typeof f1 && 0 <= --h && f1(..."" + r, (p = 1 + p, 
                (-5 != this >>> 3) < 0)), --N, p += 1, 0 < l; --l) {
                    for (d in u = s++ + void function undefined() {
                        p = 1 + p;
                    }()) {
                        p = 1 + p, (y = u[d]) && (y.Infinity = NaN == (c && ([ c[p = 1 + p, 
                        !1] ] = [ 0 ])));
                    }
                }
            }
        }
        for (g = 5; (p += 1) + {
            c: void (s && (s.next *= !0)),
            1.5: (p += 1) + (N |= s),
            a: s,
            [({
                a: s
            }.set || 6).toString()[(p += 1) + "undefined"]]: {
                "": --N
            },
            NaN: s && s[--N + ~(((s && (s.static = "24")) + (-4 >>> NaN)) % (2 === [ , 0 ].length === "c" & 25))]
        }[(p += 1) + ("" + (typeof (!0 in [ s++ + (-5 in [ (p = 1 + p, ((s && (s.in += 22)) != (NaN | this)) - (0 ^ (s = !1))) ]), [ (p = 1 + p, 
        !0) ].c ]) || 9))[(p += 1) + (N = s)]] && 0 < --g; ) {
            p += 1;
        }
        break;

      case 4 + --N:
        break;

      default:
      case s++ + this:
    }
}

N ? (--N, s++, p += 1) : ((p += 1) + (++s && s[--N + s--]) || N || 5).toString(), 
console.log(null, s, N, p, Infinity, NaN, void 0);
original result:
null 113 -2 6 Infinity NaN undefined

uglified result:
null 111 -1 1 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
var b = 10;

for (var brake1 = 5; brake1; --brake1) {
    switch (0) {
      case --b:
      case --b:
    }
}

if (b) {} else if ((--b).toString) {
    b && async_2;
}
// output: ReferenceError: async_2 is not defined
// minify: 
// options: {
//   "compress": {
//     "hoist_vars": true,
//     "keep_infinity": true,
//     "passes": 1000000,
//     "unsafe": true
//   },
//   "keep_fargs": true,
//   "keep_fnames": true,
//   "toplevel": true,
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
minify(options):
{
  "compress": {
    "hoist_vars": true,
    "keep_infinity": true,
    "passes": 1000000,
    "unsafe": true
  },
  "keep_fargs": true,
  "keep_fnames": true,
  "toplevel": true,
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  booleans
  conditionals
  evaluate
  passes
@alexlamsl alexlamsl added the bug label Oct 14, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Oct 14, 2022
alexlamsl added a commit that referenced this issue Oct 14, 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