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

Closed
alexlamsl opened this issue Apr 11, 2020 · 0 comments · Fixed by #3778
Closed

ufuzz failure #3777

alexlamsl opened this issue Apr 11, 2020 · 0 comments · Fixed by #3778
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0() {
    function f1(a) {
        {
            {
                var brake2 = 5;
                do {
                    try {
                        c = 1 + c, a && (a.foo += "foo" >>> 38..toString() >> (a && (a.foo = -5 % 22))) && ~(true >>> "b");
                    } catch (arguments_2) {
                    } finally {
                    }
                } while (a++ + (a && a[c = 1 + c, (("number" | "undefined") ^ (a = [ , 0 ][1] * true)) <= (c = c + 1, 
                [ , 0 ].length === 2) >> (Infinity !== "undefined")]) && --brake2 > 0);
            }
            for (var brake5 = 5; --b + {
                b: (c = 1 + c, (false != 3) << "foo" - 24..toString() | (a >>>= 22 > -4 ^ (5, Infinity))),
                foo: (c = 1 + c, (null << Infinity == ("" == undefined)) + (25 >> "bar" <= -1 / 4))
            } && brake5 > 0; --brake5) {
                var brake6 = 5;
                L11495: while ((c = 1 + c, (/[a2][^e]+$/ > 23..toString()) << ([ , 0 ][1] == -2) ^ /[a2][^e]+$/ >>> this == 23..toString() >>> -4) && --brake6 > 0) {
                    c = 1 + c, a = (Infinity !== 25 && "foo" < 0) % (/[a2][^e]+$/ > "" != ("function" | 22));
                }
            }
            L11496: for (var brake8 = 5; --b + (({} !== "function" == (a && (a[c = 1 + c, a <<= (("c" | 5) <= 4 >> 24..toString()) + ~([ , 0 ].length === 2 ^ "object")] = 38..toString() | "object"))) <= ((c = c + 1, 
            [ , 0 ][1]) === (-0 ^ "function"))) && brake8 > 0; --brake8) {}
            [ (c = 1 + c, +(("number" & null) == ("" ^ undefined))), (c = 1 + c, a && (a.c /= ("bar" || 4) > (undefined & "a") !== (/[a2][^e]+$/ / "a" ^ 1 < 0))), (c = 1 + c, 
            ((a = "foo" * "bar") && -4 / 24..toString()) !== (undefined ^ null || (c = c + 1, 
            0))), (c = 1 + c, ("c" >> 24..toString()) / (-3 << -1) + ([] == "undefined" ^ ([] ^ "bar"))) ].null;
        }
        {
            var brake11 = 5;
            while (typeof (typeof f2 == "function" && --_calls_ >= 0 && f2(23..toString())) && --brake11 > 0) {
                c = c + 1;
            }
        }
    }
    var NaN_1 = f1(22, "c");
    function f2(b_1, b_2) {
        var b_1 = (c = c + 1) + b_2;
    }
    function f3(Infinity, bar, NaN_1_2) {
        switch ((c = c + 1) + (typeof NaN_1 == "function" && --_calls_ >= 0 && NaN_1(a++, b--))) {
          case --b + void ((true >> 4) / ("function" !== []) <= (([ , 0 ].length === 2 !== "function") > (38..toString() && -1))):
            {
                c = 1 + c, ([ , 0 ][1] ^ -3 | (NaN_1 && (NaN_1[c = 1 + c, (false ^ 0 || "function" <= "a") & delete NaN >= 1 >> undefined] = ("object", 
                1)))) ^ (24..toString() ^ "undefined") - (NaN_1_2 && (NaN_1_2.in = "bar" || "number"));
            }
            try {
            } finally {
                c = 1 + c, 3 % 5 >>> (22 >> 22) >> (NaN_1 = [ , 0 ][1] * this < undefined % "object");
                c = 1 + c, void (-0 ^ 3, -5 % 1);
            }
            break;

          case void ("object" % "c" & (38..toString() ^ -1) ^ (/[a2][^e]+$/ || [ , 0 ].length === 2) * (5 << 0)):
            ;
            {
                var brake23 = 5;
                do {
                    {
                        var expr24 = (c = 1 + c, !23..toString() + (4 ^ [ , 0 ].length === 2) | -1 !== "a" == ("undefined", 
                        2));
                        L11497: for (var key24 in expr24) {
                            c = 1 + c, (("undefined" | -0) << (24..toString() !== [ , 0 ][1])) / (Infinity !== 24..toString() == ~[]);
                        }
                    }
                } while (--b + NaN_1 && --brake23 > 0);
            }
            break;

          case 1 === 1 ? a : b:
            {
                var brake26 = 5;
                do {
                    {
                        var brake27 = 5;
                        L11498: while ((c = 1 + c, -(!"bar" && (NaN_1_2 && (NaN_1_2[c = 1 + c, ({} | -3) != ("object", 
                        this) | (NaN_1 &= Infinity >>> -4) ^ "undefined" != /[a2][^e]+$/] = "foo" >>> "b")))) && --brake27 > 0) {
                            c = 1 + c, NaN_1 = (("function" == "bar") >>> (NaN_1 && (NaN_1.c = true ^ "number"))) % (NaN_1_2 *= "object" % undefined < (0 ^ 25));
                        }
                    }
                } while (a++ + ++a && --brake26 > 0);
            }
            var Infinity = (c = c + 1) + (b += a), a = ((c = 1 + c, void (24..toString() * 25 >= (23..toString() || -1))) || a || 3).toString();
            break;

          case --b:
            c = c + 1;
            break;
        }
        L11499: for (var brake31 = 5; typeof f5 == "function" && --_calls_ >= 0 && f5("object") && brake31 > 0; --brake31) {
            switch (a++ + (0 === 1 ? a : b)) {
              case /[abc4]/g.exec(((c = 1 + c, (NaN_1 && (NaN_1[c = 1 + c, (c = c + 1, 23..toString()) / ("object" - "bar") != (1 % this === -5 >> 23..toString())] = 3 === 1)) ^ [ , 0 ][1] !== -3 ^ (NaN_1_2 && (NaN_1_2.var += ("bar" ^ Infinity) >> undefined * "c"))) || b || 5).toString()):
                {
                    var expr33 = (c = 1 + c, ((3, undefined) & "foo" > "") - ((NaN_1 && (NaN_1.c = {} == NaN)) > (undefined == -3)));
                    L11500: for (var key33 in expr33) {
                        c = 1 + c, ((c = c + 1, NaN) ^ -2 === "number") >> (-3 - -3 ^ (2 && [ , 0 ][1]));
                    }
                }
                try {
                    c = 1 + c, (NaN_1_2 && (NaN_1_2.b = -5 != {})) <= (3 >= -2) === delete (false >>> "object");
                } finally {
                }
                break;

              default:
                ;
                {
                    var expr38 = (c = 1 + c, (5 << -3 === /[a2][^e]+$/ / 2) >> (("foo" != undefined) >= NaN + "foo"));
                    for (var key38 in expr38) {
                        c = 1 + c, ("b" || 5) * (-5 & 3) < ((NaN_1_2 && (NaN_1_2[c = 1 + c, ("foo" << -2 && !"object") + ("undefined" > -5 | "object" <= 38..toString())] = -2 != 5)) | 0 / NaN);
                    }
                }

              case --b + --b:
                for (var brake40 = 5; (c = 1 + c, "function" % -3 >= (5 ^ null) >= (5 << false === 1 + -1)) && brake40 > 0; --brake40) {
                    c = 1 + c, (c = c + 1, "c") >= ("foo" < -0), NaN_1 = (NaN - undefined) % ("object" - -4);
                }
                break;

              case a++ + NaN_1_2:
                {
                    var brake42 = 5;
                    L11501: while ((c = 1 + c, (-5 >>> /[a2][^e]+$/ == -3 * -5) - (-0 <= /[a2][^e]+$/) * (-3 / null)) && --brake42 > 0) {
                        c = 1 + c, ([] == "") * (c = c + 1, "") & (4 / -2 ^ "number" % 4);
                    }
                }
                break;
            }
        }
    }
    var parseInt = f3((c = c + 1) + {
        Infinity: (c = c + 1) + NaN_1
    }[NaN_1 >>= NaN_1]);
    function f4() {
        for (var brake44 = 5; --b + a-- && brake44 > 0; --brake44) {
            L11502: {
                for (var brake46 = 5; (c = 1 + c, (NaN !== "object" != ([ , 0 ][1] & this)) * ((24..toString() ^ [ , 0 ][1]) <= (true === 1))) && brake46 > 0; --brake46) {
                    c = 1 + c, (5 - Infinity) * (38..toString() >> 23..toString()) + (c = c + 1, -2 <= 3);
                }
                c = 1 + c, (22 === -2, -3 > 24..toString()) & (22 && false) <= (1 | this);
                try {
                    c = 1 + c, undefined * "foo" * (38..toString() && 0) <= ((22 ^ Infinity) == null - this);
                } catch (Math) {
                }
            }
        }
        {
            var brake51 = 5;
            do {
                if ((c = c + 1) + [ (c = 1 + c, ((2 ^ undefined) === ("c" && "number")) * (25 >>> 24..toString() && [ , 0 ][1] ^ "function")) ][[][c = 1 + c, 
                (NaN_1 && (NaN_1.NaN *= -0 >> "number")) * (Infinity !== -1) >> (3 <= Infinity, 
                "function" ^ [ , 0 ].length === 2)]]) {
                    c = c + 1;
                } else {
                    --b + ((c = 1 + c, (3 << 25 && 38..toString() ^ 4) == (NaN_1 && (NaN_1.in <<= false + "foo" + ("b" != "bar")))) || 6).toString()[c = 1 + c, 
                    void (("b" != true) < /[a2][^e]+$/ / /[a2][^e]+$/)];
                }
            } while ({
                a: (c = c + 1) + (b = a),
                "": --b + [ (c = 1 + c, NaN_1 && (NaN_1[--b + typeof (--b + {
                    3: (c = 1 + c, ("number" < "foo" && ([ , 0 ].length === 2, "")) === "foo" * Infinity >>> !"number"),
                    "-2": (c = 1 + c, (null - 38..toString() >= ([], NaN)) % (2 === 24..toString() || NaN_1 && (NaN_1.c += -0 - -1))),
                    0: (c = 1 + c, 23..toString() > "a" == (-2 != ([ , 0 ].length === 2)) == (NaN_1 && (NaN_1[--b + ((c = 1 + c, 
                    ({} | -4) % (38..toString() || "bar") | (NaN_1 && (NaN_1.Infinity = "number" >> 1)) !== "undefined" > "function") || 7).toString()[c = 1 + c, 
                    NaN_1 && (NaN_1.in = (-0 || 0) ^ ([ , 0 ].length === 2) < [ , 0 ][1] | (NaN_1 = (-4, 
                    25) - (Infinity === 22)))]] = (NaN_1 && (NaN_1.a = null != "a")) / (c = c + 1, -3))))
                }.NaN)] = (null === "a") << ("b" <= -0) | (5 >= "object") + ("" <= 4))) ][c = 1 + c, 
                (NaN_1 += -5 * -1 >> "b" + 25) ^ (-0 - 3, "" >> -2)],
                1.5: typeof NaN_1 == "function" && --_calls_ >= 0 && NaN_1()
            }[{
                Infinity: (c = 1 + c, (c = c + 1, 5 * "") !== (4 || "c" || "number" | /[a2][^e]+$/)),
                in: (c = 1 + c, "b" / 0 + (true ^ 4) ^ (false !== 5) >> ([ , 0 ][1] >>> -2))
            }.in] && --brake51 > 0);
        }
    }
    var Infinity_2 = f4([], -4);
}

var foo_2 = f0();

console.log(null, a, b, c, Infinity, NaN, undefined);
// uglified code
// (beautified)
var h, l = 10, f = 100, d = 10, y = 0;

h = function(a) {
    var o = 5;
    do {
        try {
            y = 1 + y, a && (a.foo += 0 >> (a && (a.foo = -5)));
        } catch (a) {}
    } while (a++ + (a && a[y = 1 + y, (0 ^ (a = 0)) <= (y += 1, 0)]) && 0 < --o);
    for (var r = 5; --d + {
        b: 1 | (a >>>= 1),
        foo: (y = 1 + (1 + y), 1)
    } && 0 < r; --r) {
        for (var f = 5; y = 1 + y, 0 ^ /[a2][^e]+$/ >>> this == 0 && 0 < --f; ) {
            y = 1 + y, a = 0;
        }
    }
    for (var e = 5; --d + ((1 == (a && (a[y = 1 + y, a <<= -2] = 38))) <= (0 == (y += 1, 
    0))) && 0 < e; --e) {}
    y = 1 + (1 + y), a && (a.c /= !0), a = NaN, y = 1 + ((y = 1 + y) + 1);
    for (var i = 5; --l, 0 < --i; ) {
        y += 1;
    }
}(22), function(a) {
    switch ((y += 1) + ("function" == typeof h && 0 <= --l && h(i++, d--))) {
      case --d + void 0:
        y = 1 + y, h && (h[y = 1 + y, !1 & 1 <= delete NaN] = 1), h = 0 * this < NaN, y = 1 + (1 + y);
        break;

      case void 0:
        var o = 5;
        do {
            var r = (y = 1 + y, 5);
            for (var f in r) {
                y = 1 + y;
            }
        } while (--d + h && 0 < --o);
        break;

      case i:
        for (var e = 5; y = 1 + y, i++ + ++i && 0 < --e; ) {}
        d += i;
        var i = "" + (void (y = 1 + (y + 1)) || i || 3);
        break;

      case --d:
        y += 1;
    }
    for (var c = 5; "function" == typeof f5 && 0 <= --l && f5("object") && 0 < c; --c) {
        switch (i++ + d) {
          case /[abc4]/g.exec((y = 1 + y, "" + (!0 ^ (h && (h[y = 1 + y, y += 1, NaN != (1 % this == -1)] = !1)) ^ a || d || 5))):
            var t = (y = 1 + y, 0 - (!1 < (h && (h.c = !1))));
            for (var v in t) {
                y = 1 + y, y += 1;
            }
            try {
                y = 1 + y;
            } finally {}
            break;

          default:
            var n = (y = 1 + y, 0);
            for (var N in n) {
                y = 1 + y;
            }

          case --d + --d:
            for (var s = 5; y = 1 + y, 0 < s; --s) {
                y = 1 + y, y += 1, h = NaN;
            }
            break;

          case i++ + a:
            y = 1 + y;
        }
    }
}((y += 1, y += 1, void (h >>= h))), function() {
    for (var a = 5; --d + f-- && 0 < a; --a) {
        for (var o = 5; y = 1 + y, !1 * (1 != (0 & this)) && 0 < o; --o) {
            y = 1 + y, y += 1;
        }
        y = 1 + y;
        try {
            y = 1 + y;
        } catch (a) {}
    }
    for (var r = 5; (y += 1) + [ 0 ][[][y = 1 + (1 + y), !0 * (h && (h.NaN *= 0)) >> 1]] ? y += 1 : (--d, 
    y = 1 + y, h && (h.in <<= !1 + "foo" + !0), y = 1 + y), {
        a: (y += 1) + (d = f),
        "": --d + [ (y = 1 + y, h && (h[--d + typeof (--d + {
            3: !1,
            "-2": (y = 1 + (1 + y), !1 % (h && (h.c += 1))),
            0: (y = 1 + y, 0 == (h && (h[--d + (y = 1 + y, ("" + (-4 | !0 !== (h && (h.Infinity = 0)) || 7))[y = 1 + y, 
            h && (h.in = 0 | (h = 25))])] = (h && (h.a = !0)) / (y += 1, -3))))
        }.NaN)] = 1)) ][y = 1 + y, 0 ^ (h += 5)],
        1.5: "function" == typeof h && 0 <= --l && h()
    }[y = 1 + ((y = 1 + y) + 1), 1] && 0 < --r; ) {}
}(), console.log(null, f, d, y, 1 / 0, NaN, void 0);


original result:
null 94 93 108 Infinity NaN undefined

uglified result:
null 94 93 103 Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
f2 && f2((0).toString);

function f2(b_1) {
    var b_1 = b_2;
}
// output: ReferenceError: b_2 is not defined
// minify: 
// options: {
//   "compress": {
//     "passes": 1000000,
//     "unsafe": true
//   },
//   "toplevel": true
// }
minify(options):
{
  "compress": {
    "passes": 1000000,
    "unsafe": true
  },
  "toplevel": true
}

Suspicious compress options:
  inline
  reduce_vars
  side_effects
  unsafe
@alexlamsl alexlamsl added the bug label Apr 11, 2020
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Apr 11, 2020
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Apr 11, 2020
alexlamsl added a commit that referenced this issue Apr 11, 2020
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