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

Closed
alexlamsl opened this issue Jan 16, 2023 · 0 comments · Fixed by #5778
Closed

ufuzz failure #5777

alexlamsl opened this issue Jan 16, 2023 · 0 comments · Fixed by #5778
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0(async, a_2, a_1) {
    {
        var b_2 = function f1(bar) {
            function f2(foo_1) {
                L26175: for (var brake3 = 5; typeof f4 == "function" && --_calls_ >= 0 && f4("function") && brake3 > 0; --brake3) {
                    c = 1 + c, (38..toString() >= ([ 3n ][0] > 2), -5 || "b") < (([] ?? -3) && -4 == "a");
                }
            }
            var c = f2(null, (c && (c[c = 1 + c, false / "bar" !== (a_2 = NaN == "undefined") !== +[] << (false | false)] <<= 5 <= true)) + (true >= [ , 0 ][1]) && (c = c + 1, 
            false) == 38..toString() + "");
            function f3([ a_1_1_1, a_1_1, a_1 ], ...c_2) {
                (c = c + 1) + 22;
            }
            var Infinity_2 = f3([ (c = c + 1) + !a, (c = c + 1) + (bar = function() {
            }), -3 ], {});
            function f4(b, bar_1) {
                function f5({
                    3: a_1_1,
                    next: a_1_2
                }, async_1_1, async_1) {
                    c = 1 + c, (-1 >>> "foo" != (bar && ([ bar[c = 1 + c, delete ((undefined >= true) % (-1 >> 22))] ] = [ "function" % "foo" ]))) <= (2 > !0o644n) % (23..toString() && -5);
                    c = 1 + c, (-1 <= 25 ^ (-3, 0)) / ((25 || "object") > (true, 
                    /[a2][^e]+$/));
                }
                var async_2 = f5({});
            }
            function f6(Infinity) {
                return;
                try {
                    if (c = 1 + c, (1 | 5) ^ undefined === "function" ?? 4 >> /[a2][^e]+$/ & -3 * NaN) {
                        c = 1 + c, 24..toString() / "foo" % (-1 - 0) == (-24..toString() !== 22 + []);
                    }
                } catch (c_2) {} finally {}
                for (var brake12 = 5; void (NaN > 22 & (Infinity && (Infinity.b = ("function", 
                22))) & (1 !== "b") < (-1 !== "object")) && brake12 > 0; --brake12) {
                    continue;
                }
            }
            var await = f6(null, 22, a_2 && typeof a_2.null == "function" && --_calls_ >= 0 && a_2.null((c = 1 + c, 
            (/[a2][^e]+$/ !== "" ^ "undefined" >> undefined) - (25 % ([ , 0 ].length === 2) || "foo" - "a")), (c = 1 + c, 
            (3 / "a" & ([ , 0 ][1] ^ [ , 0 ][1])) == 1 >> 1 >= +{})));
        }(5, --b + b++, -5);
    }
    return;
}

var a_2 = f0(--b + {
    "\t": [ --b + void (("bar" | "bar" && -4 === "c") > ("object" !== "object") % ({} ^ "number")), (c = c + 1) + a ][[ (c = c + 1) + (3 in [ [ a && typeof a.c == "function" && --_calls_ >= 0 && a.c(-2, 0) ].foo ]) ]],
    a: a,
    "-2": (22 in [ --b + -b, (c = c + 1) + (b + 1 - .1 - .1 - .1 || 1).toString()[--b], --b + (1 === 1 ? a : b), b = a ] || a || 3).toString(),
    c: a++ + (a++ + ((c = c + 1) + !((c = c + 1, "c" < Infinity) >= (3 == "function" | 2 >>> {}))) || a || 3).toString(),
    foo: typeof a == "function" && --_calls_ >= 0 && a(({
        a
    } = a++ + (a &= (a++ + (typeof f2 == "function" && --_calls_ >= 0 && f2``) || a || 3).toString()) || {}))
}[a++ + [ ("number" !== "number") >= (5 ^ true) ?? (4 < "") * ("object" >= 23..toString()), ..."" + a, /[abc4]/.test((b++ || b || 5).toString()) ][(c = c + 1) + (a && typeof a.async == "function" && --_calls_ >= 0 && a.async())]]);

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

function f0(a, c, n) {
    var o, t;
    --b, b++, (t && (t[t = 1 + t, NaN !== (c = !1) !== 0] <<= !1)) + !0 && (t += 1), 
    t = void (0 <= --_calls_ && (t = 1 + t, ([ o[t = 1 + t, !0] ] = [ NaN ]))), 
    o = function() {}, t = t + 1 + 1 + 1, c && "function" == typeof c.null && 0 <= --_calls_ && c.null(1 - (25 % (2 === [ , 0 ].length) || NaN), (t = 1 + (1 + t), 
    !0));
}

var a_2 = f0(--b + {
    "\t": [ --b + void 0, (c += 1) + a ][[ (c += 1) + (3 in [ [ a && "function" == typeof a.c && 0 <= --_calls_ && a.c(-2, 0) ].foo ]) ]],
    a: a,
    "-2": (22 in [ --b - b, (c += 1) + ("" + (b + 1 - .3 || 1))[--b], --b + a, b = a ] || a || 3).toString(),
    c: a++ + (a++ + ((c += 1) + (c += 1, !0)) || a || 3).toString(),
    foo: "function" == typeof a && 0 <= --_calls_ && a(({
        a
    } = a++ + (a &= (a++ + ("function" == typeof f2 && 0 <= --_calls_ && f2``) || a || 3).toString()) || {}))
}[a++ + [ !1, ..."" + a, /[abc4]/.test((b++ || b || 5).toString()) ][(c += 1) + (a && "function" == typeof a.async && 0 <= --_calls_ && a.async())]]);

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

uglified result:
evalmachine.<anonymous>:1
var _calls_=10,a=100,b=10,c=0;function f0(a,c,n){var o,t;--b,b++,(t&&(t[t=1+t,NaN!==(c=!1)!==0]<<=!1))+!0&&(t+=1),t=void(0<=--_calls_&&(t=1+t,([o[t=1+t,!0]]=[NaN]))),o=function(){},t=t+1+1+1,c&&"function"==typeof c.null&&0<=--_calls_&&c.null(1-(25%(2===[,0].length)||NaN),(t=1+(1+t),!0))}var a_2=f0(--b+{"\t":[--b+void 0,(c+=1)+a][[(c+=1)+(3 in[[a&&"function"==typeof a.c&&0<=--_calls_&&a.c(-2,0)].foo])]],a:a,"-2":(22 in[--b-b,(c+=1)+(""+(b+1-.3||1))[--b],--b+a,b=a]||a||3).toString(),c:a+++(a+++((c+=1)+(c+=1,!0))||a||3).toString(),foo:"function"==typeof a&&0<=--_calls_&&a(({a}=a+++(a&=(a+++("function"==typeof f2&&0<=--_calls_&&f2``)||a||3).toString())||{}))}[a+++[!1,...""+a,/[abc4]/.test((b++||b||5).toString())][(c+=1)+(a&&"function"==typeof a.async&&0<=--_calls_&&a.async())]]);console.log(null,a,b,c,1/0,NaN,void 0);
                                                                                                                                                   ^

TypeError: Cannot set properties of undefined (setting 'true')
    at f0 (evalmachine.<anonymous>:1:148)
    at evalmachine.<anonymous>:1:297
    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
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2558:20)
// reduced test case (output will differ)

// (beautified)
function f0() {
    (function f1(bar) {
        function f2() {
            f4();
        }
        f2();
        bar = function() {};
        function f4() {
            console.log(bar);
        }
    })(5);
}

f0();
// output: 5
// 
// minify: undefined
// 
// 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
  inline
  passes
  reduce_vars
  sequences
  unused
@alexlamsl alexlamsl added the bug label Jan 16, 2023
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jan 16, 2023
alexlamsl added a commit that referenced this issue Jan 16, 2023
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