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

Closed
alexlamsl opened this issue Nov 7, 2019 · 0 comments · Fixed by #3574
Closed

ufuzz failure #3573

alexlamsl opened this issue Nov 7, 2019 · 0 comments · Fixed by #3574
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0(foo) {
    function f1(bar_2, parseInt, parseInt_1) {
        return 0 === 1 ? a : b;
        var a_2 = --b + [];
    }
    var parseInt_1 = f1();
    function f2(parseInt_1) {
        function f3() {
            switch (c = 1 + c, (parseInt_1 += (-4 && null) == -5 >= 5) >> (this ^ -1) * (parseInt_1 && (parseInt_1[(c = 1 + c, 
            1 != undefined && null >>> NaN && (4 ^ [], 0 < Infinity))] += ([ , 0 ].length === 2) + ([ , 0 ].length === 2)))) {
              case c = 1 + c, -(false + "bar") <= ("object" & "object" | [] - 25):
                ;
                break;

              case c = 1 + c, "undefined" <= -1 >= (-5 < "b") || "" > "foo" & "number" << false:
                ;
                break;

              case c = 1 + c, (c = c + 1, -3) * ("" >>> 5) || (null > undefined) >> ("object" > []):
                ;
                break;

              case c = 1 + c, void (parseInt_1 && (parseInt_1.NaN = -1 / /[a2][^e]+$/)) >= ([] % "c" != ("c" || 3)):
                ;
                break;
            }
        }
        var a = f3(typeof f5 == "function" && --_calls_ >= 0 && f5((c = 1 + c, c = c + 1, 
        (22 >> ([ , 0 ].length === 2)) / ("function" && 3)), (c = 1 + c, parseInt_1 = ((parseInt_1 && (parseInt_1[(c = 1 + c, 
        "function" + "foo" >= (parseInt_1 && (parseInt_1[(c = 1 + c, (-1 - Infinity > 24..toString() * 0) >>> (-0 / /[a2][^e]+$/ && undefined * "c"))] ^= 3 ^ 2)) || this >= undefined > (3 >= [ , 0 ][1]))] += 0 & 5)) <= "a" << "a") >>> (-4 == "function") - (0 >= 24..toString()))), Infinity);
    }
    var b = f2(false, [ , 0 ][1], NaN);
    function f4(undefined, bar_1, b) {
        for (var brake5 = 5; typeof parseInt_1 == "function" && --_calls_ >= 0 && parseInt_1(0, ~(("a" ^ "foo") % (bar_1 && (bar_1[(c = 1 + c, 
        (bar_1 && (bar_1.Infinity = (-3 ^ "object", true + {}))) === "a" >> -4 <= -3 + 1)] %= false ^ 25)) | (bar_1 && (bar_1[[ (c = 1 + c, 
        (4 ^ "c" ^ 5 >= 22) & (parseInt_1 && (parseInt_1[[ (c = 1 + c, -2 / "" & -0 % {} ^ -1 + 3 === 3 + Infinity), (c = 1 + c, 
        (parseInt_1 -= (parseInt_1 = 2 * null) & [ , 0 ][1] >> 2) ^ "b" === /[a2][^e]+$/ === ({} || this)), (c = 1 + c, 
        (bar_1 && (bar_1[(c = 1 + c, ("bar" & "foo") + false * "bar" > ((parseInt_1 >>>= "c" * "b") ^ -5 << undefined))] += {} | "c")) > ("function" & "foo") | -5 <= [ , 0 ][1] >= (-1 != Infinity)), (c = 1 + c, 
        ("object" * {} === ("undefined" && 25)) <= (1 >>> "" ^ (3 || "number"))) ].null] = (undefined * 2, 
        "foo", null)))) ].NaN] >>>= ("a" !== true) + -4 * 38..toString())))) && brake5 > 0; --brake5) {
            var foo_1 = function f5() {
                c = 1 + c, undefined >> 24..toString() !== "foo" >>> [ , 0 ][1] & (3 && "b") <= (NaN != "object");
                c = 1 + c, (c = c + 1, 2 >>> null) != (~"number", [ , 0 ][1] % "c");
            }((c = 1 + c, ((bar_1 && (bar_1[(c = 1 + c, ("c", "object") << (foo_1 %= 5 ^ 22) <= (false >>> this == ("b", 
            -4)))] = 4 << null)) | 4 + 22) >>> ({} << 0 ^ [] <= NaN)), (c = 1 + c, (4 !== undefined ^ "b" < 1) >= ("bar" !== -5) >> (22 != -4)));
        }
        var c_1 = a++ + "a", a_2 = (c = c + 1) + ~a;
    }
    var b_2 = f4(--b + (b = a), -1);
    function f6() {
        if (b--) {
            if (--b + (typeof f3 == "function" && --_calls_ >= 0 && f3((c = 1 + c, ("object" >>> "bar" << 38..toString() + 0) + (("object" ^ 38..toString()) & (c = c + 1, 
            1))), (c = 1 + c, ((parseInt_1 += -0 != "number") >>> (NaN < true)) * ([ , 0 ][1] < "" ^ (0 ^ NaN))), "") || 9).toString()[!function arguments_2() {
            }()]) {
                var expr12 = a++ + (1 === 1 ? a : b);
                for (var key12 in expr12) {
                    c = 1 + c;
                    var b = expr12[key12];
                    {
                        var brake13 = 5;
                        while ((c = 1 + c, (({} === -2) + ([] << 24..toString())) % ((true ^ 2) > ("b" | -0))) && --brake13 > 0) {
                            c = 1 + c, ((/[a2][^e]+$/ | -5) ^ (parseInt_1 *= NaN ^ Infinity)) / (Infinity <= undefined != -5 > "number");
                        }
                    }
                }
            } else {
                switch (--b + --a) {
                  default:
                  case --b + +b:
                    c = 1 + c, (2 - {}) % (38..toString() && [ , 0 ].length === 2) != +(5 ^ false);
                    break;

                  case a++ + [ (c = 1 + c, b_2 && (b_2.b %= ("a" == [ , 0 ][1]) - "b" % [ , 0 ][1] === ((-2 & "b") == "" >> -1))), (c = 1 + c, 
                    (38..toString() << -0) + 5 % {} + ((Infinity ^ 22) & ("bar" & "b"))), (c = 1 + c, 
                    parseInt_1 ^= ((b_2 && (b_2.var += "foo" & "foo")) >>> (-3, "foo")) * (-1 & "bar", 
                    c = c + 1, "bar")) ]:
                    break;

                  case typeof f5 == "function" && --_calls_ >= 0 && f5(38..toString(), -5):
                    c = 1 + c, ("object" & false) >> (23..toString() >>> -3) !== ("function" < -5) - (4, 
                    -2);
                    c = 1 + c, (-4 != Infinity || Infinity ^ this) * (-2 != -0 && (c = c + 1, ""));
                    break;
                }
            }
        }
        c = c + 1;
    }
    var parseInt_1_1 = f6(a++ + ~a);
    function f7(b) {
        {
            var brake20 = 5;
            while (a++ + (--b + 25) && --brake20 > 0) {
                try {
                    var parseInt;
                } finally {
                    var b = (c = 1 + c, ([ , 0 ][1] <= 3) + void -4 || null % [] % (5 || 25)), b_1 = (c = 1 + c, 
                    "undefined" >> [ , 0 ][1] <= (5 <= "c") ^ (b_1 = (undefined >> -4) + (22 < "bar")));
                    switch (c = 1 + c, (Infinity ^ 0) / (38..toString() - this) < (c = c + 1, "" ^ "a")) {
                      case c = 1 + c, ("bar" == 5 && "foo" ^ {}) > (("c" | {}) <= (undefined || 0)):
                        ;
                        break;

                      case c = 1 + c, (parseInt_1_1 && (parseInt_1_1.var += "function" == 2) && -2 < 24..toString()) & (4 >= "foo") % (null && -1):
                        ;
                        break;

                      case c = 1 + c, (c = c + 1, -3) % (38..toString() === "foo") <= ((parseInt_1_1 && (parseInt_1_1[(c = 1 + c, 
                        +3 * (c = c + 1, false) === (("object" ^ -3) !== 24..toString() >>> -5))] = "number" << Infinity)) | -5 % ([ , 0 ].length === 2)):
                        ;
                        break;

                      case c = 1 + c, 2 * 24..toString() * (2 || "foo") != ("b" + "undefined" ^ 22 >= "b"):
                        ;
                        break;
                    }
                }
            }
        }
        c = c + 1;
    }
    var b_2_2 = f7(1, --b + (0 === 1 ? a : b));
}

var a = f0(-4, "function", (c = c + 1) + [ --b + (a++ + "" || a || 3).toString() ][/[abc4]/.test(((c = c + 1) + a || b || 5).toString())]);

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

function f0() {
    var i = f, f = function(a) {
        !function() {
            switch (c = 1 + c, (a += !1) >> (-1 ^ this) * (a && (a[(c = 1 + c, 0)] += 2))) {
              case c = 1 + c, !1:
              case c = 1 + c, !0:
              case c = 1 + c, 0 * (c += 1, -3) || 0:
              case c = 1 + c, !0 <= void (a && (a.NaN = NaN)):
            }
        }("function" == typeof f5 && 0 <= --_calls_ && f5((c = 1 + c, 11 / 3), (c = 1 + (c += 1), 
        a = ((a && (a[(c = 1 + c, (a && (a[(c = 1 + c, 0)] ^= 1)) <= "functionfoo" || !0 < (void 0 <= this))] += 0)) <= 0) >>> 0)));
    }(!1), t = function(f) {
        for (var n = 5; "function" == typeof i && 0 <= --_calls_ && i(0, ~(0 % ((-1)[(c = 1 + c, 
        !1 === ((-1).Infinity = !0 + {}))] %= 25) | ((-1)[[ (c = 1 + c, 4 & (i && (i[[ (c = 1 + c, 
        0), (c = 1 + c, !1 ^ (i -= 0 & (i = 0))), (c = 1 + c, 0 < ((-1)[(c = 1 + c, ((i >>>= NaN) ^ -5 << f) < NaN)] += 0) | !0), (c = 1 + c, 
        !0) ].null] = null))) ].NaN] >>>= -151))) && 0 < n; --n) {
            var o = ((-1)[(c = 1 + (c = 1 + c), "object" << (o %= 19) <= (!1 >>> this == -4))] = 4, 
            c = 1 + (c = 1 + (c = 1 + c)), void (c += 1));
        }
        a++, c += 1;
    }(--f + (f = a)), o = function() {
        if (o--) {
            if (--o + ("" + ("function" == typeof f3 && 0 <= --_calls_ && f3((c = 1 + c, 0), (c = 1 + (c += 1), 
            0 * ((i += !0) >>> !1)), "") || 9))[!0]) {
                var f = a++ + a;
                for (var n in f) {
                    var o = f[n];
                    c = 1 + (c = 1 + c);
                }
            } else {
                switch (--o + --a) {
                  default:
                  case --o + +o:
                    c = 1 + c;
                    break;

                  case a++ + [ (c = 1 + c, t && (t.b %= !1)), (c = 1 + c, NaN), (c = 1 + c, i ^= ((t && (t.var += 0)) >>> "foo") * (c += 1, 
                    "bar")) ]:
                    break;

                  case "function" == typeof f5 && 0 <= --_calls_ && f5("38", -5):
                    c = 1 + (c = 1 + c), c += 1;
                }
            }
        }
        c += 1;
    }(a++);
    !function(f) {
        for (var n = 5; 25 + a++ + --f && 0 < --n; ) {
            switch (c = 1 + (c = 1 + (c = 1 + c)), 0 / ("38" - this) < 0) {
              case c = 1 + (c += 1), !1:
              case c = 1 + c, (f = NaN) & (o && (o.var += !1) && !0):
              case c = 1 + c, c += 1, NaN <= (-0 | (o && (o[(c = 1 + c, 3 * (c += 1, !1) === !0)] = 0))):
              case c = 1 + c, !0:
            }
        }
        c += 1;
    }(1, --f);
}

a = f0(-4, "function", (c += 1) + [ --b + "" + (a++ + "" || a || 3) ][/[abc4]/.test("" + ((c += 1) + a || b || 5))]), 
console.log(null, a, b, c, 1 / 0, NaN, void 0);
original result:
null undefined 9 15 Infinity NaN undefined

uglified result:
null undefined 9 30 Infinity NaN undefined

minify(options):
{
  "compress": {
    "keep_fargs": false,
    "passes": 1000000,
    "sequences": 1000000,
    "unsafe": true,
    "unsafe_Function": true,
    "unsafe_math": true,
    "unsafe_proto": true,
    "unsafe_regexp": true
  }
}
@alexlamsl alexlamsl added the bug label Nov 7, 2019
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Nov 7, 2019
alexlamsl added a commit that referenced this issue Nov 7, 2019
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