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

Closed
alexlamsl opened this issue May 2, 2018 · 0 comments · Fixed by #3114
Closed

ufuzz failure #3113

alexlamsl opened this issue May 2, 2018 · 0 comments · Fixed by #3114

Comments

@alexlamsl
Copy link
Collaborator

https://travis-ci.org/alexlamsl/UglifyJS2/builds/373920501

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

function f0(b) {
    function f1(b_2, bar_1, NaN_1) {
        var bar = a++ + !(!(bar_1 *= 2 & 1) < true % 2 * ("function" * /[a2][^e]+$/)), Math = void a;
        if (a++ + a++) {
            var expr3 = !((!1 != ("a" ^ -2)) + (Infinity < "bar" | (a_2 && (a_2.NaN = 5 && null))));
            for (var key3 in expr3) {
                c = 1 + c;
                var a_2 = expr3[key3];
                L16061: {
                    c = 1 + c, c = c + 1, (-3 != -1) > -5 >> /[a2][^e]+$/;
                    c = 1 + c, bar_1 && (bar_1[!((bar_1 && (bar_1.in = "c" == "c" || null + null)) >>> ("bar" - "b" >>> ("foo" >> 4)))] += (true >> {}) * ("c" + 23..toString()) == (-5 != -2) >> (c = c + 1, 
                    "a"));
                }
            }
        } else {
            switch (typeof foo_1 != "string") {
              case a++ + /[abc4]/.test((a++ + {
                    c: (c = 1 + c, (([ , 0 ].length === 2 ^ 22) > false * "c") << ((0 ^ 38..toString()) === (c = c + 1, 
                    [ , 0 ][1]))),
                    length: (c = 1 + c, c = c + 1, 5 % "" ^ ("c" | -3)),
                    undefined: (c = 1 + c, (3 <= 1 === -0 >>> "a") <= (23..toString() - "function" ^ (-2 && ""))),
                    NaN: (c = 1 + c, NaN_1 && (NaN_1[-(((c = c + 1, 3) < (1 < 4)) + (-0 && -3) / (/[a2][^e]+$/ / true))] = ([ , 0 ].length === 2) - -2 >> (c = c + 1, 
                    true) ^ (this === [] | 22 === -2))),
                    3: (c = 1 + c, [ , 0 ][1] + NaN ^ -5 * 5 ^ (38..toString() === Infinity) <= (NaN_1 && (NaN_1.a += -3 !== ([ , 0 ].length === 2))))
                }[(c = 1 + c, (null >= 22) >> 24..toString() % undefined === (bar_1 = null >= 1) * ("" >> "function"))] || b || 5).toString()):
                c = c + 1;
                break;

              case (c = c + 1) + a_2:
                break;

              case NaN_1:
                try {
                    c = 1 + c, 22 - [ , 0 ][1] - ([ , 0 ].length === 2) / "c" ^ ({} >= NaN) - ("" << "a");
                } finally {
                }
                break;

              case --b + void ((a_2 && (a_2.var = [ , 0 ].length === 2 != {})) / (a_2 && (a_2[(c = 1 + c, 
                (/[a2][^e]+$/ === 5, void "") < (38..toString() - "bar") % (([ , 0 ].length === 2) >> undefined))] += "" % "foo")) % (a_2 &= (this == {}) >= ({} & 24..toString()))):
                break;
            }
        }
    }
    var c_2 = f1(false, -1, undefined);
    function f2(c_2_1) {
        {
            var brake11 = 5;
            do {
                (c = c + 1) + (a-- ? c_2_1 && c_2_1.null : 1 === 1 ? a : b);
            } while ([][a++ + (typeof f4 == "function" && --_calls_ >= 0 && f4((c = 1 + c, (null >= NaN ^ -1 * Infinity) === ("b" & 1) >> (Infinity, 
            "a")), (c = 1 + c, (0, 0) << ("a" ^ "function") !== ("function" >= -4 == (c_2_1 && (c_2_1.NaN = -0 > -3)))), 1))] && --brake11 > 0);
        }
        switch (a++ + -0) {
          case (c = c + 1) + (b = a):
            break;

          case (c = c + 1) + (typeof f0 == "function" && --_calls_ >= 0 && f0("foo")):
            {
                var expr14 = 1 === 1 ? a : b;
                L16062: for (var key14 in expr14) {
                    c = 1 + c;
                    var c_2_1 = expr14[key14];
                    {
                        var brake15 = 5;
                        L16063: while ((c = 1 + c, (c = c + 1, "c" >= /[a2][^e]+$/) | (c_2 = 3 >> "") <= ([ , 0 ][1] & "undefined")) && --brake15 > 0) {
                            c = 1 + c, c = c + 1, (this, "number") && 23..toString() === [];
                        }
                    }
                }
            }
            --b + delete b;
            break;

          case b = a:
            1;
            for (var brake19 = 5; null && brake19 > 0; --brake19) {
                c = c + 1;
            }
            break;

          case /[abc4]/.test(((c = c + 1) + (/[abc4]/.test(((c = 1 + c, ([] ^ "function") > ("bar" === -1) & 38..toString() + {} >> (24..toString(), 
            true)) || b || 5).toString()) || a || 3).toString() || b || 5).toString()):
            switch ((c = c + 1) + void a) {
              case --b + -b:
                c = 1 + c, c_2 && (c_2[--b + ((c = c + 1) + ((c = 1 + c, (("foo" <= [ , 0 ][1]) >> ("" << {})) + ((c_2_1 += 1 != "b") || ("function" || -0))) || 4).toString()[(c = 1 + c, 
                (NaN !== /[a2][^e]+$/) / (-5 !== "object") ^ ([] !== -3 ^ false <= true))] || a || 3).toString()] = 0 != -4 != ("number" || []) ^ (-5 * "b" ^ null > /[a2][^e]+$/));
                break;

              case 0 === 1 ? a : b:
                c = 1 + c, 38..toString() - 1 | -0 << "foo" && (c = c + 1, 24..toString() | this);
                c = 1 + c, c_2_1 && (c_2_1[(c = c + 1) + [ (c = 1 + c, -4 >>> this === (25 === true) != ((c = c + 1, 
                -0) ^ -4 << "object")), (c = 1 + c, ([] & 2) + (1 >= "function") != (-5 >= Infinity) << 2 + "undefined"), (c = 1 + c, 
                (-3 ^ [ , 0 ][1]) / (22 != -1) !== ((c = c + 1, "bar") & ("a" && true))), (c = 1 + c, 
                (([ , 0 ].length === 2) + Infinity ^ ~[ , 0 ][1]) <= (undefined << {}) % (c_2_1 && (c_2_1.foo = "b" || Infinity))), (c = 1 + c, 
                (c_2 && (c_2[b--] /= [] + 38..toString() ^ (c_2 && (c_2.var += undefined === -0)))) / (undefined >>> 0 <= -3 * "a")) ][(c = c + 1) + ((-0 * NaN ^ {} > "c") - ({} * -2 >> (0 === 23..toString())))]] += (38..toString() + ([ , 0 ].length === 2) >= (-3 >= -1)) / (c = c + 1, 
                false <= 38..toString()));
                break;

              case --b + c_2:
                c = 1 + c, ("a" ^ "") < (false ^ "foo") || 1 + "" <= ("function", this);
                c = 1 + c, c = c + 1, c = c + 1, c = c + 1, false;
                break;

              case --b + [ (c = 1 + c, ((25 || 24..toString()) ^ (25 ^ -3)) != !23..toString() < 0 % {}), (c = 1 + c, 
                c_2 >>= (c_2_1 && (c_2_1.c = (null == -1) >> (false ^ 3))) >= (22 == -0 !== (c_2_1 && (c_2_1[(c = 1 + c, 
                (NaN !== 1) + ("number" || "function") && -3 <= "bar" ^ ([ , 0 ][1] || false))] = ([], 
                "b"))))) ]:
                c = 1 + c, (c_2_1 && (c_2_1[[]] = (false != "c") << (-0 >>> false))) !== 23..toString() << -5 < 3 * -4;
                break;
            }
            try {
                {
                }
            } catch (b_1) {
                c = 1 + c, b_1 && (b_1[(c = c + 1) + (b + 1 - .1 - .1 - .1)] += (("a" || 3) ^ "b" * "foo") != -5 / "number" % (c_2_1 && (c_2_1[(c = 1 + c, 
                c_2_1 = ([] - 23..toString() ^ [ , 0 ][1] >>> "undefined") / (c = c + 1, /[a2][^e]+$/ == "b"))] = 0 & 5)));
                c = 1 + c, (c = c + 1, "undefined" > 22) <= (b_1 && (b_1.var += (-2 ^ "") != "b" <= -4));
            } finally {
                c = 1 + c, c_2_1 && (c_2_1[a++ + []] = ("bar" >> "foo" != ("number" !== -5)) << ((24..toString(), 
                0) >= ("number" > undefined)));
                c = 1 + c, -2 / 4 !== ([ , 0 ].length === 2 ^ 1) ^ (5 >= {}) % (false / "bar");
            }
        }
    }
    var a_2 = f2(a++ + !function a_2() {
        {
            var expr34 = (c = 1 + c, (-3 <= 5) % (0 <= -5) >> (a_2 = 25 ^ "b") + ([ , 0 ].length === 2) % -3);
            for (var key34 in expr34) {
                c = c + 1;
            }
        }
        L16064: for (var brake36 = 5; a_2 && brake36 > 0; --brake36) {
            c = 1 + c, 3 | 0 || undefined === "a" || ("c" !== "number") + (-3 >> "b");
        }
        var undefined_1 = (c = c + 1) + (a_2 && a_2[(c = 1 + c, -1 + -5 === ({} || -5) !== (("a" && "") ^ Infinity + {}))]);
    }());
    function f3(b_1, a_1) {
        {
            for (var brake40 = 5; typeof a_2 == "function" && --_calls_ >= 0 && a_2() && brake40 > 0; --brake40) {
                switch (c = 1 + c, 5 << /[a2][^e]+$/ !== NaN > "object" !== /[a2][^e]+$/ / "object" < ([] | [])) {
                  case c = 1 + c, (-4 === []) >> ("function" || 2) !== (NaN == 5) >> (24..toString() <= "a"):
                    ;
                    break;

                  default:
                    ;

                  case c = 1 + c, undefined >>> -4 == (0 || 2) || ~NaN >>> (-3 << ""):
                    ;
                    break;

                  case c = 1 + c, +("undefined" / undefined) ^ (c_2 = -3 - -2 - ([ , 0 ].length === 2 !== true)):
                    ;
                    break;
                }
            }
            {
                var expr42 = a++ + {
                    0: (c = 1 + c, c_2 && (c_2.var += (23..toString() % 25 == (Infinity, "b")) - (~25 & (4 ^ 24..toString())))),
                    in: (c = 1 + c, 4 / 2 >= (true >= null) !== (-1 == this) + (24..toString() === NaN)),
                    set var(foo) {
                        this.Infinity *= -1 << -1;
                    }
                }[(c = 1 + c, ((-0 <= false) >>> 0 - null) * ((a_2 = "function" || Infinity) * (a_2 && (a_2[(c = 1 + c, 
                (({} == NaN) >= (b_1 += {} || 22)) % (-1 > /[a2][^e]+$/ > 1 % "foo"))] = -3 && 25))))];
                for (var key42 in expr42) {
                    c = 1 + c;
                    var a_2 = expr42[key42];
                    break;
                }
            }
        }
        c = c + 1;
    }
    var b = f3(void (((undefined >>> "bar") + (c = c + 1, NaN)) * (0 > undefined ^ NaN >> -1)));
    function f4(a, b_2, a_2_2) {
        {
            var brake45 = 5;
            do {
                ("b" <= true === (b_2 && (b_2[(c = 1 + c, (("foo" >= 24..toString()) + ("bar" >> 22)) % ("bar" > -1 != ([ , 0 ][1] != 1)))] += null ^ false))) > ("bar" >= null === -2 / "b");
            } while ((c = c + 1) + {
                foo: --b + a_2,
                "\t": b--,
                "\t": (c = c + 1) + +("a" * 24..toString() ^ (a_2 && (a_2[(c = 1 + c, (c = c + 1, 
                "function") / ("b" - 4) >>> (0 === "bar" && 4 ^ /[a2][^e]+$/))] = "" > 3))),
                a: a++ + (("object" >>> [ , 0 ][1]) * (-2 - 2) >= (undefined ^ 23..toString()) * ("bar" - undefined)),
                3: 1 === 1 ? a : b
            }.null && --brake45 > 0);
        }
        if (a_2) {
            return b++;
        } else {
            L16065: {}
        }
    }
    var b_1 = f4("c", /[abc4]/.test((--b + (c = c + 1, (a_2 = 3 ^ -4) & (a_2 && (a_2.foo >>>= "b" && []))) || b || 5).toString()));
    function f5(b_1, bar, a_2_2) {
        c = c + 1;
        var a_2_2 = !function Math() {
            if (c = 1 + c, ([ , 0 ][1] < /[a2][^e]+$/) * ~{} - (Infinity, [ , 0 ].length === 2) / (-2 >>> "undefined")) {
                c = 1 + c, /[a2][^e]+$/ <= 5 === +"" !== (3 <= "a" == (0 && NaN));
            }
        }(), bar_2 = b_1 && b_1.a;
    }
    var bar_2 = f5(a++ + b_1, "a", false);
}

var b_1 = f0();

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

function f0(f) {
    var i = function(r, t, o) {
        if (a++, t *= 0, a++ + a++) {
            var e = !(!0 + (!1 | (i && (i.NaN = null))));
            for (var n in e) {
                var i = e[n];
                c = 1 + (c = 1 + c), c = 1 + (c += 1), t && (t[!((t && (t.in = !0)) >>> 0)] += NaN == !0 >> (c += 1, 
                "a"));
            }
        } else {
            switch ("string" != typeof foo_1) {
              case a++ + /[abc4]/.test((a++ + {
                    c: (c = 1 + c, !1 << (38 == (c += 1, 0))),
                    length: (c = 1 + c, c += 1, -3),
                    undefined: (c = 1 + c, !0),
                    NaN: (c = 1 + c, o),
                    3: (c = 1 + c, -25)
                }[(c = 1 + c, 0 == 0 * (t = !1))] || f || 5).toString()):
                c += 1;
                break;

              case (c += 1) + i:
                break;

              case o:
                try {
                    c = 1 + c;
                } finally {}
                break;

              case --f + (i && (i.var = !0), i && (i[(c = 1 + c, !1)] += NaN), void (i &= 0 <= (this == {}))):
            }
        }
    }(0, -1, void 0);
    function s(a, r) {
        for (var t = 5; r && (r[(c = 1 + c, 0)] += 0), (c += 1) + {
            foo: --f - 1,
            "\t": f--,
            "\t": (c += 1) + +(NaN ^ ((-1)[(c = 1 + c, c += 1, 0)] = !1)),
            a: a++ + !1,
            3: a
        }.null && 0 < --t; ) {}
        return f++;
    }
    !function(r) {
        for (var t = 5; c += 1, a-- && r && r.null, [][a++ + (0 <= --_calls_ && s((c = 1 + c, 
        !0), (c = 1 + c, 0 !== (0 == (r && (r.NaN = !0))))))] && 0 < --t; ) {}
        switch (a++ - 0) {
          case (c += 1) + (f = a):
            break;

          case (c += 1) + ("function" == typeof f0 && 0 <= --_calls_ && f0("foo")):
            var o = a;
            for (var e in o) {
                c = 1 + c, r = o[e];
                for (var n = 5; c = 1 + c, c += 1, !0 | (i = 3) <= 0 && 0 < --n; ) {
                    c = 1 + c, c += 1;
                }
            }
            --f, delete f;
            break;

          case f = a:
            break;

          case /[abc4]/.test(((c += 1) + (/[abc4]/.test((c = 1 + c, f || 5).toString()) || a || 3).toString() || f || 5).toString()):
            switch ((c += 1) + void 0) {
              case --f - f:
                c = 1 + c, i && (i[--f + ((c += 1) + ("" + (c = 1 + c, 0 + ((r += !0) || "function") || 4))[(c = 1 + c, 
                1)] || a || 3).toString()] = 1);
                break;

              case f:
                c = 1 + c, c = 1 + (c += 1), r && (r[(c += 1) + [ (c = 1 + c, -4 >>> this === !1 != (-4 ^ (c += 1, 
                -0))), (c = 1 + c, !1), (c = 1 + c, -3 != (!0 & (c += 1, "bar"))), (c = 1 + c, -1 <= 0 % (r && (r.foo = "b"))), (c = 1 + c, 
                (i && (i[f--] /= "38" ^ (i && (i.var += !1)))) / !1) ][(c += 1) + 0]] += !1 / (c += 1, 
                !0));
                break;

              case --f + i:
                c = 1 + (c = 1 + c), c += 1, c += 1, c += 1;
                break;

              case --f + [ (c = 1 + c, !0), (c = 1 + c, i >>= (r && (r.c = 0)) >= (!1 !== (r && (r[(c = 1 + c, 
                0)] = "b")))) ]:
                c = 1 + c, r && (r[[]] = 1);
            }
            c = 1 + c, r && (r[a++ + []] = 2), c = 1 + c;
        }
    }(a++ + !function a() {
        var r = (c = 1 + c, NaN >> 1 + (a = 25));
        for (var t in r) {
            c += 1;
        }
        for (var o = 5; a && 0 < o; --o) {
            c = 1 + c;
        }
        c += 1, a && (c = 1 + c);
    }()), f = function(r) {
        for (var t = 5; "function" == typeof n && 0 <= --_calls_ && n() && 0 < t; --t) {
            switch (c = 1 + c, !0) {
              case c = 1 + c, !1:
                break;

              default:
              case c = 1 + c, 7:
              case c = 1 + c, NaN ^ (i = -1):
            }
        }
        var o = a++ + {
            0: (c = 1 + c, i && (i.var += -4)),
            in: (c = 1 + c, !0 !== (-1 == this) + !1),
            set var(c) {
                this.Infinity *= -1 << -1;
            }
        }[(c = 1 + c, (n = "function") * (n && (n[(c = 1 + c, ((r += {}) <= !1) % !1)] = 25)) * 1)];
        for (var e in o) {
            c = 1 + c;
            var n = o[e];
            break;
        }
        c += 1;
    }(void (c += 1)), s("c", /[abc4]/.test((--f + (c += 1, -1 & ((-1).foo >>>= [])) || f || 5).toString())), 
    a++, c = 1 + (c = 1 + (c += 1));
}

var b_1 = f0();

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

uglified result:
null 142 10 197 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
  }
}

Suspicious compress options:
  evaluate
  passes
  reduce_vars
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue May 2, 2018
alexlamsl added a commit that referenced this issue May 2, 2018
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue May 3, 2018
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue May 3, 2018
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue May 3, 2018
alexlamsl added a commit that referenced this issue May 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant