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

Closed
alexlamsl opened this issue Jan 7, 2023 · 0 comments · Fixed by #5773
Closed

ufuzz failure #5772

alexlamsl opened this issue Jan 7, 2023 · 0 comments · Fixed by #5773
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

export function f0(b) {
    try {
        {
            var brake2 = 5;
            do {
                switch ((a++ + -(b && (b[a++ + "foo"] ^= ("c" instanceof 3) + ("" ^ 25) !== (true - -4 !== (b = 3 + 0)))) || 4).toString()[b++]) {
                  case --b + (0 === 1 ? a : b):
                    break;

                  default:
                    {
                        var brake4 = 5;
                        while ({
                            Infinity: a++ + (b && typeof b.in == "function" && --_calls_ >= 0 && (/[abc4]/g.exec(((c = 1 + c, 
                            b && (b.then &= "foo" >>> 4 >= "" - [ , 0 ][1] < ((b && (b.__proto__ = "number" * [ , 0 ][1])) | 24..toString() > "undefined"))) || b || 5).toString()), 
                            b.in)()),
                            3: (c = c + 1) + --b,
                            static: (c = c + 1) + /[abc4]/.test(("number" in {
                                "-2"(bar_1, a_1) {
                                },
                                foo: (c = 1 + c, "undefined" + -3 >= (1 < true) !== 25 % NaN > 2 + {}),
                                async: (c = 1 + c, b += (null || this) - (24..toString() < 24..toString()) - (b = "function" - false - (/[a2][^e]+$/ >= 25)))
                            } || b || 5).toString()),
                            3: (c = c + 1) + b--,
                            "": ((b = (b |= (22 ^ 24..toString()) == (null === 25)) | ({} != "a" || "a" >> "")) || 4).toString()[typeof f2 == "function" && --_calls_ >= 0 && f2(1)]
                        } && --brake4 > 0) {
                            var expr5 = --b + {
                                set: --b + a--
                            };
                            for (var key5 in expr5) {
                                c = c + 1;
                            }
                        }
                    }
                    {
                        var brake7 = 5;
                        while (typeof f1 == "function" && --_calls_ >= 0 && f1("undefined") && --brake7 > 0) {
                            return;
                            typeof b == "function" && --_calls_ >= 0 && b("foo", NaN);
                        }
                    }
                    {
                        var expr9 = a++ + (b && b.done);
                        for (var key9 in expr9) {
                            try {
                                {
                                    var brake11 = 5;
                                    while (a++ + (b && typeof b.a == "function" && --_calls_ >= 0 && b.a``) && --brake11 > 0) {
                                        var expr12 = a++ + {
                                            [(c = 1 + c, (1 != Number(0xdeadn << 16n | 0xbeefn) === (c = c + 1, 
                                            /[a2][^e]+$/)) << ((NaN & true) <= ("object" && 0)))]: (c = 1 + c, 
                                            (c = c + 1, "b" === -3) !== ({} <= "number" || "object" % 25))
                                        }[c = 1 + c, key9 && (key9[a++ + ++a] = ([] == -3 & -2 === Infinity) != (key9 && ([ key9.c ] = [ ("b" ^ [ , 0 ][1]) + ("bar" - 3) ])))];
                                        for (var [ key12 ] in expr12) {
                                            {
                                                return c = 1 + c, ((1 ^ NaN) != (25 && 38..toString())) >> ("" + -0 > (undefined >= "number"));
                                            }
                                        }
                                    }
                                }
                            } finally {
                                {
                                    c = 1 + c, (b && (b[--b + (typeof b_1 == "undefined")] **= "c" | "object" | null + null)) === (5 >= /[a2][^e]+$/) + -1;
                                    c = 1 + c, (3 || 38..toString()) == (38..toString() !== NaN) || ("b" ^ NaN) >>> ([ , 0 ].length === 2 == 4);
                                }
                                c = c + 1;
                                if ((c = c + 1) + b--) {}
                                c = c + 1;
                            }
                        }
                    }

                  case a++ + (b && typeof b.next == "function" && --_calls_ >= 0 && b.next(..."" + b)):
                    if (/[abc4]/g.exec(((c = c + 1) + (typeof b == "function" && --_calls_ >= 0 && b(b--)) || b || 5).toString())) {
                        b ? +function() {}() : (c = c + 1) + --b;
                    }
                    break;

                  case 0 === 1 ? a : b:
                    break;
                }
            } while (typeof f0 == "function" && --_calls_ >= 0 && f0() && --brake2 > 0);
        }
    } catch (b_2) {
        {
            var brake23 = 5;
            L26976: while (--b + [].b && --brake23 > 0) {
                var brake24 = 5;
                do {
                    L26977: {
                        if (--b + [ (c = 1 + c, (NaN > -2) << ("foo" < 23..toString()) ^ -(38..toString() < [ , 0 ][1])), (c = 1 + c, 
                        (38..toString(), [ , 0 ][1]) - (/[a2][^e]+$/, 0) + (false ^ "bar" ^ 4 >>> this)), (c = 1 + c, 
                        (4 < "bar") + (3 - "c") || (null || 25) ^ (5 | -4)), (c = 1 + c, 
                        +(([ 3n ][0] > 2 === "a") + ([] & {}))), (c = 1 + c, (b_2 && (b_2.NaN >>>= (b && (b.c += [] < undefined)) === (b && (b.static >>>= ([ , 0 ].length === 2) + -2)))) ^ /[a2][^e]+$/ / -2 << (38..toString() & -4)) ]) {
                            -1;
                        } else {}
                        c = c + 1;
                    }
                } while (b_2 && --brake24 > 0);
            }
        }
    }
    {
        var brake30 = 5;
        while ({
            Infinity: --b + -0
        }[a++ + []] && --brake30 > 0) {
            return a++ + new function(b, bar, c_1) {
                {
                    return typeof b !== "string";
                }
            }();
        }
    }
    var foo_1 = 38..toString() in [ typeof f2 == "function" && --_calls_ >= 0 && f2(a++ + ([ (c = 1 + c, 
    (foo_1 += false === 3) * (b && (b[c = 1 + c, (b = ("foo" || "c") == ("function" & "c")) < void ([ 3n ][0] > 2) << void ([ , 0 ].length === 2)] >>= (-42n).toString() >> -2)) != (c = c + 1, 
    a_1 = [ , 0 ][1] == ([ , 0 ].length === 2))) ].var || 3).toString()[+((c = c + 1, 
    foo_1 <<= 3 < 1) ^ (this >> 38..toString()) - ("function" ^ Infinity))], --b + (typeof NaN_1 != "undefined")) ? (c = c + 1) + b-- : ~(((b && (b.undefined = [ , 0 ][1] | false)) + (false << [])) % (a_1 && (a_1.__proto__ += (c = c + 1, 
    false) < (undefined || [])))) ], a_1 = a++ + foo_1;
}

var b_2 = f0();

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

function f0(b) {
    try {
        var brake2 = 5;
        do {
            switch ((a++ - (b && (b[a++ + "foo"] ^= 25 + ("c" instanceof 3) !== (5 != (b = 3)))) || 4).toString()[b++]) {
              case --b + b:
                break;

              default:
                for (var key5, brake4 = 5; a++, b && "function" == typeof b.in && 0 <= --_calls_ && (/[abc4]/g.exec((c = 1 + c, 
                (b && (b.then &= !0 < ((b && (b.__proto__ = NaN)) | "undefined" < 24..toString())) || b || 5).toString())), 
                b.in)(), --b, c = c + 1 + 1, /[abc4]/.test(("number" in {
                    "-2"(bar_1, a_1) {},
                    foo: !1 != 2 + {} < NaN,
                    async: (c = 1 + (c = 1 + c), b += this - (24..toString() < 24..toString()) - (b = NaN))
                } || b || 5).toString()), c += 1, ((b = --b | 0 == (22 ^ 24..toString()) | ("a" != {} || 0)) || 4).toString()["function" == typeof f2 && 0 <= --_calls_ && f2(1)], 
                0 < --brake4; ) {
                    for (key5 in --b + {
                        set: --b + a--
                    }) {
                        c += 1;
                    }
                }
                var key9, brake7 = 5;
                if ("function" == typeof f1 && 0 <= --_calls_ && f1("undefined") && 0 < --brake7) {
                    return;
                }
                for (key9 in a++ + (b && b.done)) {
                    try {
                        for (var key12, brake11 = 5; a++ + (b && "function" == typeof b.a && 0 <= --_calls_ && b.a``) && 0 < --brake11; ) {
                            for ([ key12 ] in a++ + {
                                [(c = 1 + c, (1 != Number(0xdeadn << 16n | 0xbeefn) === /[a2][^e]+$/) << !0)]: (c = 1 + (c += 1), 
                                !1 !== ({} <= "number" || NaN))
                            }[c = 1 + (c += 1), key9 && (key9[a++ + ++a] = (-3 == [] & !1) != (key9 && ([ key9.c ] = [ NaN ])))]) {
                                return c = 1 + c, (1 != 38..toString()) >> !1;
                            }
                        }
                    } finally {
                        c = 1 + c, b && (b[--b + ("undefined" == typeof b_1)] **= 0), 
                        c = 1 + c, 38..toString(), b--, c = (c += 1) + 1 + 1;
                    }
                }

              case a++ + (b && "function" == typeof b.next && 0 <= --_calls_ && b.next(..."" + b)):
                !/[abc4]/g.exec(((c += 1) + ("function" == typeof b && 0 <= --_calls_ && b(b--)) || b || 5).toString()) || b || (c += 1, 
                --b);
                break;

              case b:
            }
        } while ("function" == typeof f0 && 0 <= --_calls_ && f0() && 0 < --brake2);
    } catch (b_2) {
        for (var brake23 = 5; --b + [].b && 0 < --brake23; ) {
            for (var brake24 = 5; --b, c = 1 + c, 23..toString(), 38..toString(), 
            c = 1 + c, 38..toString(), c = 1 + (c = 1 + (c = 1 + c)), b_2 && (b_2.NaN >>>= (b && (b.c += [] < void 0)) === (b && (b.static >>>= (2 === [ , 0 ].length) + -2))), 
            38..toString(), c += 1, b_2 && 0 < --brake24; ) {}
        }
    }
    var brake30 = 5;
    if ({
        Infinity: --b
    }[a++ + []] && 0 < --brake30) {
        return a++ + new function(b, bar, c_1) {
            return !0;
        }();
    }
    var foo_1 = 38..toString() in [ "function" == typeof f2 && 0 <= --_calls_ && f2(a++ + ([ (c = 1 + c, 
    (foo_1 += !1) * (b && (b[c = 1 + c, (b = !1) < 0] >>= (-42n).toString() >> -2)) != (c += 1, 
    brake30 = 0 == (2 === [ , 0 ].length))) ].var || 3).toString()[c += 1, (foo_1 <<= !1) ^ this >> 38..toString()], --b + ("undefined" != typeof NaN_1)) ? (c += 1) + b-- : ~(((b && (b.undefined = 0)) + (!1 << [])) % (brake30 && (brake30.__proto__ += (c += 1, 
    !1 < [])))) ], brake30 = a++ + foo_1;
}

var b_2 = f0();

console.log(null, a, b, c, 1 / 0, NaN, void 0);

export {
    f0
};
original result:
null 166 10 990 Infinity NaN undefined

uglified result:
null 166 10 1001 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
function f0() {
    var brake30;
    while (--brake30) {
        return 0;
    }
    var foo_1 = console.log() && (a_1 = 1) ? 0 : a_1.__proto__, a_1 = foo_1;
}

f0();
// output: TypeError: Cannot read property '__proto__' of undefined
// minify: 
// 
// options: {
//   "mangle": false,
//   "module": false,
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
minify(options):
{
  "mangle": false,
  "module": false,
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  dead_code
  loops
  merge_vars
@alexlamsl alexlamsl added the bug label Jan 7, 2023
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Jan 7, 2023
alexlamsl added a commit that referenced this issue Jan 7, 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