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

Closed
alexlamsl opened this issue Jun 16, 2024 · 0 comments · Fixed by #5845
Closed

ufuzz failure #5841

alexlamsl opened this issue Jun 16, 2024 · 0 comments · Fixed by #5845
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0() {
    function* f1() {
        for (var brake1 = 5; void ((("bar" ^ "undefined") == (Number(0xdeadn << 16n | 0xbeefn) & Infinity)) + ("function" * ([ , 0 ].length === 2) << (1 === -4))) && brake1 > 0; --brake1) {
            switch ((c = c + 1) + (b = a)) {
              case (c = c + 1) + (a && a.Infinity):
                c = c + 1;
                break;

              default:
                {
                    var brake4 = 5;
                    L58696: while ((c = 1 + c, (2 + 24..toString()) / (a && (a.next ^= "undefined" || "b")), 
                    "foo" >= "function" ?? (NaN ?? "c")) && --brake4 > 0) {
                        c = 1 + c, (-5 > 2 ?? (a += 3 < 5)) >>> ((22 & "") <= 24..toString() / 1);
                    }
                }

              case typeof f2 == "function" && --_calls_ >= 0 && f2`${c = 1 + c, 
                ((23..toString() == "function") + (null ^ 5)) / (("a" >> undefined) * (25 !== -4))}
${c = 1 + c, void ((-5 ^ "foo") === ([], -5))}
 `:
                {
                    var brake6 = 5;
                    do {
                        c = 1 + c, ("a" === "object", 0 == 24..toString()) / ("undefined" << -4 == (0 === 4));
                    } while ((c = 1 + c, ((NaN | 0) ^ NaN < 1) == ([ , 0 ][1] ?? 1) - (a && (a.static >>= 22 <= ([ , 0 ].length === 2)))) && --brake6 > 0);
                }
                {
                    var brake8 = 5;
                    L58697: do {
                        c = 1 + c, -0 % 1 % (a |= "function" * "undefined") * ((5 == true) + (-0 >> 25));
                    } while ((c = 1 + c, c = c + 1, "undefined" < -4 || (NaN ?? "b")) && --brake8 > 0);
                }
                c = 1 + c, 0 >> -4 <= 38..toString() + undefined !== (c = c + 1, 
                22 & 25);
                break;

              case a && typeof a.value == "function" && --_calls_ >= 0 && a.value((c = 1 + c, 
                true <= "number" >= 3 << -2 ^ (c = c + 1, -2 || -5))):
                for (var brake11 = 5; (c = 1 + c, -((-1 | [ , 0 ][1]) != (-4 ^ []))) && brake11 > 0; --brake11) {
                    c = 1 + c, ((-2, 24..toString()) ^ ("" ^ "function")) === ((4 ^ 1) & 22 % "");
                }
                c = c + 1;
                break;
            }
        }
        switch (void ((a = (c = c + 1, "a") || 3 % NaN) && (-5 / 24..toString() || "object" < []))) {
          case b >>>= a:
            break;

          case typeof b != "symbol":
            break;

          case (c = c + 1) + (true in [ void function yield_2() {
                class C0 {
                    set [(c = 1 + c, (-3 > -2) >> (a = Infinity % /[a2][^e]+$/) == (this ^ null) < -0 % "b")](b) {
                        this.static += ([ 3n ][0] > 2) >>> "a";
                    }
                    in = (c = 1 + c, ((Object.isExtensible(yield_2) && (yield_2.static >>>= 23..toString() == "object")) <= 5 / 2) >> (23..toString() + "undefined" & this << ([ 3n ][0] > 2)));
                    #next(a_2) {
                    }
                }
            }(), b--, (c = c + 1) + 4, --b + function() {
            } ]):
            {
                var brake15 = 5;
                do {
                    {
                        var brake16 = 5;
                        L58698: do {
                            c = 1 + c, (("b" || [ , 0 ][1]) && "function" !== /[a2][^e]+$/) ^ [] * "a" < (22 >= -3);
                        } while ((c = 1 + c, a && ({
                            done: a.b
                        } = {
                            done: ("function" >>> 38..toString()) * !NaN !== (!0o644n >> "function" == (-4 | 1))
                        })) && --brake16 > 0);
                    }
                } while (--b + (0 in {
                    in: (c = 1 + c, ("a" / NaN << (-4 > 0)) / (a += (-2 <= "c", 
                    c = c + 1, -1))),
                    "-2": (c = 1 + c, (c = c + 1, Infinity >> "object") % (([ , 0 ][1] >>> ([ , 0 ].length === 2)) % (NaN || 5)))
                }) && --brake15 > 0);
            }
            {
                return a++ + !((2 >= "number" < (a = "a" % "number")) - (-2 && 0 && 3 - "foo"));
            }
            {
                var brake19 = 5;
                do {
                    {
                        var brake20 = 5;
                        do {
                            c = 1 + c, (a && (a[(c = c + 1) + (typeof f2 == "function" && --_calls_ >= 0 && f2` \`${c = 1 + c, 
                            ("b" !== 38..toString() | this != 0) & (a && (a.in = this === true)) >> ({}, 
                            "undefined")}\\`)] = (5 < "", -3 || "b"))) <= ("foo" >= "") ** (23..toString() == NaN);
                        } while ((c = 1 + c, (0 ^ "foo") * void "a" > ("" === "bar") * ({} | false)) && --brake20 > 0);
                    }
                } while ((c = c + 1) + +(("function" >= "") >> ([] < "number") | (3 << 22, 
                "object" + -0)) && --brake19 > 0);
            }

          case typeof b != "object":
            {
                var brake22 = 5;
                while (--b + /[abc4]/g.exec(((c = 1 + c, ("foo" > 25 | (/[a2][^e]+$/, 
                "foo")) + (4 >>> 3 & delete false)) || b || 5).toString()) && --brake22 > 0) {
                }
            }
            break;
        }
    }
    var yield_1 = f1().next();
    function f2() {
        return;
    }
    var yield_2 = f2("bar");
    function f3() {}
    var async_1 = f3([][(c = c + 1) + {
        next: a++ + (0 === 1 ? a : b)
    }[--b + (typeof f4 == "function" && --_calls_ >= 0 && f4())]]);
    function f4() {
        if ({
            [b++]: [ (c = 1 + c, (1 >>> "object" !== true <= 38..toString()) >>> delete ("a" / Infinity)) ]
        }[void function async() {
            c = 1 + c, (yield_1 && (yield_1[async_1] = ("foo" == "object") < "b" - ([ , 0 ].length === 2))) ^ (3, 
            false) / ("number" * 5);
        }()]) {
            var b_1;
        } else {
            typeof f5 == "function" && --_calls_ >= 0 && f5(38..toString());
        }
    }
    var yield_1_1 = f4(1, "c");
    function f5(arguments_1, yield_1_1_2) {
        function f6() {
            for (var brake29 = 5; (c = 1 + c, ((c = c + 1, 22) && ("number" ?? "foo")) & (yield_1_1 = ([ , 0 ].length === 2) >= -5 >= ("c", 
            -3))) && brake29 > 0; --brake29) {
                c = 1 + c, "number" % ([ , 0 ].length === 2) & (c = c + 1, 24..toString()) | -0 % {} << (yield_1 = NaN - null);
            }
        }
        var arguments_1_1 = f6(yield_2 && yield_2.length);
        function f7(b_2, await_2) {
            function f8(b_2, await, foo_2) {
            }
            var yield_1 = f8((c = 1 + c, (22 || 22) / ("b" != -0) % (("bar" && "") != (c = c + 1, 
            38..toString()))), (c = 1 + c, (-1 === -0 & -3 > "") / (await_2 && (await_2.static -= 0 / "b" ^ 3 >= -0))));
            function* f9(arguments_2) {
            }
            var await_2_1 = f9();
        }
        var a_2 = f7([ , 0 ][1]);
    }
}

var a = f0(38..toString(), 22, NaN);

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

function f0() {
    var n = function*() {
        switch (c += 1, void (a = "a")) {
          case b >>>= a:
          case "symbol" != typeof b:
            break;

          case (c += 1) + (!0 in [ void class {
                [(c = 1 + c, a = NaN)]() {}
            }, b--, (c += 1) + 4, --b + function() {} ]):
            var n = 5;
            do {
                for (var o = 5; c = 1 + (c = 1 + c), a && (({
                    done: a.b
                } = {
                    done: 0 !== (!0o644n >> "function" == -3)
                }), 0 < --o); ) {}
            } while (--b + (0 in {
                in: (c = 1 + c, 0 / (a += -1)),
                "-2": (c = 1 + (c += 1), c += 1, 0 % ((0 >>> (2 === [ , 0 ].length)) % 5))
            }) && 0 < --n);
            return a++ + !+(!1 < (a = NaN));

          case "object" != typeof b:
            for (var e = 5; --b + /[abc4]/g.exec((c = 1 + c, (b || 5).toString())) && 0 < --e; ) {}
        }
    }().next(), o = void 0, e = (c += 1, a++, --b, void (0 <= --_calls_ && l()));
    function l() {
        !{
            [b++]: [ 0 ]
        }[c = 1 + (c = 1 + c), void (n && (n[e] = !1 < "b" - (2 === [ , 0 ].length)))] && 0 <= --_calls_ && t();
    }
    function t() {
        o && o.length;
        for (var a = 5; c = 1 + c, c += 1, "number" & -3 <= (-5 <= (2 === [ , 0 ].length)) && 0 < a; --a) {
            c = 1 + c, c += 1, n = NaN;
        }
        c = 1 + c, c = 1 + (c += 1), K;
    }
    l();
}

a = f0("38", 22, NaN), console.log(null, a, b, c, 1 / 0, NaN, void 0);

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

uglified result:
evalmachine.<anonymous>:1
var _calls_=10,a=100,b=10,c=0;function f0(){var n=function*(){switch(c+=1,void(a="a")){case b>>>=a:case"symbol"!=typeof b:break;case(c+=1)+(!0 in[void class{[(c=1+c,a=NaN)](){}},b--,(c+=1)+4,--b+function(){}]):var n=5;do{for(var o=5;c=1+(c=1+c),a&&(({done:a.b}={done:0!==(!0o644n>>"function"==-3)}),0<--o););}while(--b+(0 in{in:(c=1+c,0/(a+=-1)),"-2":(c=1+(c+=1),c+=1,0%((0>>>(2===[,0].length))%5))})&&0<--n);return a+++!+(!1<(a=NaN));case"object"!=typeof b:for(var e=5;--b+/[abc4]/g.exec((c=1+c,(b||5).toString()))&&0<--e;);}}().next(),o=void 0,e=(c+=1,a++,--b,void(0<=--_calls_&&l()));function l(){!{[b++]:[0]}[c=1+(c=1+c),void(n&&(n[e]=!1<"b"-(2===[,0].length)))]&&0<=--_calls_&&t()}function t(){o&&o.length;for(var a=5;c=1+c,c+=1,"number"&-3<=(-5<=(2===[,0].length))&&0<a;--a)c=1+c,c+=1,n=NaN;c=1+c,c=1+(c+=1),K}l()}a=f0("38",22,NaN),console.log(null,a,b,c,1/0,NaN,void 0);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ^

ReferenceError: K is not defined
    at t (evalmachine.<anonymous>:1:815)
    at l (evalmachine.<anonymous>:1:683)
    at f0 (evalmachine.<anonymous>:1:582)
    at evalmachine.<anonymous>:1:823
    at Script.runInContext (node:vm:141:12)
    at Object.runInContext (node:vm:297:6)
    at run_code_vm (/Users/runner/work/UglifyJS/UglifyJS/test/sandbox.js:273:12)
    at Object.exports.run_code (/Users/runner/work/UglifyJS/UglifyJS/test/sandbox.js:36:38)
    at run_code (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2116:20)
    at /Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2571:29
// reduced test case (output will differ)

// (beautified)
var _calls_ = 1;

function f0() {
    var async_1 = f4();
    function f4() {
        if ({}[0]) {} else {
            f5 && _calls_ && f5();
        }
    }
    f4();
    function f5() {
        for (var brake29 = 5; brake29; --brake29) {}
        function f7(await_2) {
            await_2 && await_2.static;
        }
        f7();
    }
}

f0();
// output: 
// minify: ReferenceError: f is not defined
// options: {
//   "compress": {
//     "passes": 1000000,
//     "sequences": 1000000,
//     "unsafe": true,
//     "unsafe_Function": true,
//     "unsafe_math": true,
//     "unsafe_proto": true,
//     "unsafe_regexp": true
//   },
//   "module": false,
//   "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
  },
  "module": false,
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  conditionals
  evaluate
  inline
  join_vars
  passes
  pure_getters
  reduce_funcs
  reduce_vars
  side_effects
  unused
  yields

Suspicious options:
  rename
@alexlamsl alexlamsl added the bug label Jun 16, 2024
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jun 16, 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