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

Closed
alexlamsl opened this issue Aug 12, 2024 · 0 comments · Fixed by #5916
Closed

ufuzz failure #5915

alexlamsl opened this issue Aug 12, 2024 · 0 comments · Fixed by #5916
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0(NaN_1, arguments_2, a_1) {
    try {
        {
            var foo_1 = function f1(bar, b_2) {}([ , 0 ].length === 2, /[a2][^e]+$/, (c = c + 1) + (1 === 1 ? a : b));
        }
    } catch (a_1) {
        {
            var yield_2 = function f2(bar_1, ...bar) {
                switch (a++ + (1 === 1 ? a : b)) {
                  case a++ + (b = a):
                    c = c + 1;
                    break;

                  case /[abc4]/.test((a++ + (b = a) || b || 5).toString()):
                    break;

                  case {
                        "": --b + /[abc4]/.test(((c = 1 + c, (arguments_2 = (Number(0xdeadn << 16n | 0xbeefn) <= -0) / ("" ?? [ , 0 ].length === 2)) ^ (bar = "function" >= -3) != "number" - 23..toString()) || b || 5).toString()),
                        c: b = a
                    }:
                    {
                        var c_1 = function f3(undefined_1) {
                        }();
                    }
                    break;

                  case --b + delete (-3 >>> NaN >>> (22 && "b") | (c_1 += 22 == "b") >>> {} % -5):
                    {
                        var brake7 = 5;
                        while (--b + (typeof f4 == "function" && --_calls_ >= 0 && f4((c = 1 + c, 
                        ("function" >>> "" ^ ("function" ^ "a")) > (c_1 /= "a" ^ 0) - (this >> NaN)))) && --brake7 > 0) {
                            c = c + 1;
                        }
                    }
                }
            }(a_1, 24..toString() in {
                Infinity: a++ + /[abc4]/g.exec((!b || b || 5).toString())
            } ? (c = c + 1) + {
                "": (c = c + 1) + [ (c = 1 + c, ("b" ^ 4) != -4 * /[a2][^e]+$/ === (-5 << 24..toString() || "foo" / "function")) ][a++ + 25],
                a: a++ + (arguments_2 *= false in [])
            }[a++ + (1 === 1 ? a : b)] : a_1);
        }
    }
    {
        var brake10 = 5;
        while ((b = a) && --brake10 > 0) {
            var a_2 = function f4(foo_1) {
                try {
                    if ([ ((c = 1 + c, (+ -0 & -3 <= 24..toString()) < (-3 % 38..toString() ^ "number" * 3)) || 7).toString()[c = 1 + c, 
                    (foo_1 && (foo_1.then *= 38..toString() >> "number" <= -2 >> 24..toString())) < (a_1 = "c" >= 5 | 3 ^ 5)] ].var) {
                        c = c + 1;
                    } else {
                        c = c + 1;
                    }
                } catch (b_2) {} finally {
                    (c = c + 1) + (1 === 1 ? a : b);
                }
                if ((c = c + 1) + foo_1) {
                    var a_1 = function f5(a_2, foo, await_1) {
                        c = 1 + c, (-4 + 0 && (c = c + 1, 25)) >> (("function", 
                        25) & (2 && 22));
                        {
                            var brake21 = 5;
                            do {
                                c = 1 + c, a_2 && (a_2[void function foo() {
                                    c = 1 + c, (22, 23..toString()) != 0 * 25 && "foo" << 0 >= (arguments_2 && (arguments_2[c = 1 + c, 
                                    (-3 && 1) % (5 <= 1) >>> (3 >= this) ** (1 % "c")] -= (Infinity, 
                                    "undefined")));
                                    c = 1 + c, (("" && -5) <= 5 << true) >> (/[a2][^e]+$/ + 38..toString() & "a" >>> 5);
                                    c = 1 + c, (-5 === 2) + (-3 == -5) >= ([ , 0 ][1] * /[a2][^e]+$/ < (null <= 22));
                                }()] ??= (-0 >>> false & "b" % "undefined") < ("undefined" >= 23..toString(), 
                                null ^ /[a2][^e]+$/));
                            } while ((c = 1 + c, (foo_1 && ({
                                foo: foo_1.get
                            } = {
                                foo: "function" & false
                            })) | "" !== 1 | (-2 >> 0) - (foo_1 && (foo_1.null = false >> "undefined"))) && --brake21 > 0);
                        }
                    }(function c_1() {});
                }
            }((c = c + 1) + (typeof f4 == "function" && --_calls_ >= 0 && f4(--b + NaN_1, 2)));
        }
    }
}

var a_2 = f0("foo");

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

function f0(n, t, o) {
    try {
        c += 1;
    } catch (o) {
        !function() {
            switch (a++ + a) {
              case a++ + (b = a):
                c += 1;
                break;

              case /[abc4]/.test((a++ + (b = a) || b || 5).toString()):
                break;

              case {
                    "": --b + /[abc4]/.test((c = 1 + c, (!0 ^ (t = (+("" + (0xdeadn << 16n | 0xbeefn)) <= -0) / "") || b || 5).toString())),
                    c: b = a
                }:
                var n = void 0;
                break;

              case --b + (n += !1, !0):
                for (var o = 5; --b + ("function" == typeof f4 && 0 <= --_calls_ && f4((c = 1 + c, 
                (n /= 0) - (this >> NaN) < 0))) && 0 < --o; ) {
                    c += 1;
                }
            }
        }("24" in {
            Infinity: a++ + /[abc4]/g.exec((!b || b || 5).toString())
        } && (c = 1 + (c = c + 1 + 1), a++, a++, t *= !1 in [], a++));
    }
    for (var f = 5; (b = a) && 0 < --f; ) {
        var i = void 0, e = (c += 1) + ("function" == typeof f4 && 0 <= --_calls_ && f4(--b + n, 2));
        try {
            c = 1 + (c = 1 + c), e && (e.then *= !1), c += 1;
        } catch (c) {} finally {
            c += 1;
        }
        if ((c += 1) + e) {
            c = 1 + c, c += 1;
            for (var i = 5; c = 1 + c, (void 0)[void function() {
                c = 1 + c, t && (t[c = 1 + c, NaN >>> (this <= 3) ** NaN] -= "undefined"), 
                c = 1 + (c = 1 + c);
            }()] ??= !1, c = 1 + c, !0 | (e && ({
                foo: e.get
            } = {
                foo: 0
            })) | -2 - (e && (e.null = 0)) && 0 < --i; ) {}
        }
    }
}

var a_2 = f0("foo");

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

uglified result:
evalmachine.<anonymous>:1
var _calls_=10,a=100,b=10,c=0;function f0(n,t,o){try{c+=1}catch(o){!function(){switch(a+++a){case a+++(b=a):c+=1;break;case/[abc4]/.test((a+++(b=a)||b||5).toString()):break;case{"":--b+/[abc4]/.test((c=1+c,(!0^(t=(+(""+(0xdeadn<<16n|0xbeefn))<=-0)/"")||b||5).toString())),c:b=a}:var n=void 0;break;case--b+(n+=!1,!0):for(var o=5;--b+("function"==typeof f4&&0<=--_calls_&&f4((c=1+c,(n/=0)-(this>>NaN)<0)))&&0<--o;)c+=1}}("24"in{Infinity:a+++/[abc4]/g.exec((!b||b||5).toString())}&&(c=1+(c=c+1+1),a++,a++,t*=!1 in[],a++))}for(var f=5;(b=a)&&0<--f;){var i=void 0,e=(c+=1)+("function"==typeof f4&&0<=--_calls_&&f4(--b+n,2));try{c=1+(c=1+c),e&&(e.then*=!1),c+=1}catch(c){}finally{c+=1}if((c+=1)+e){c=1+c,c+=1;for(var i=5;c=1+c,(void 0)[void function(){c=1+c,t&&(t[c=1+c,NaN>>>(this<=3)**NaN]-="undefined"),c=1+(c=1+c)}()]??=!1,c=1+c,!0|(e&&({foo:e.get}={foo:0}))|-2-(e&&(e.null=0))&&0<--i;);}}}var a_2=f0("foo");console.log(null,a,b,c,1/0,NaN,void 0);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^

TypeError: Cannot read properties of undefined (reading 'undefined')
    at f0 (evalmachine.<anonymous>:1:814)
    at evalmachine.<anonymous>:1:898
    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:2572:29
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2559:20)
// reduced test case (output will differ)

// (beautified)
var c = 0;

function f0() {
    while (1) {
        var a_2 = function f4(foo_1) {
            try {
                0();
            } catch (b_2) {}
            if (foo_1) {
                var a_1 = function f5(a_2) {
                    do {
                        console.log(a_2[0]);
                    } while (1);
                }(function c_1() {});
            }
        }(c + 1);
    }
}

f0();
// output: Error: Script execution timed out after 100ms
// minify: TypeError: Cannot read properties of undefined (reading '0')
// 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:
  evaluate
  functions
  if_return
  inline
  passes
  reduce_vars
  side_effects
  unused
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