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

Most likely V8 specific issue #1764

Closed
alexlamsl opened this issue Apr 2, 2017 · 1 comment
Closed

Most likely V8 specific issue #1764

alexlamsl opened this issue Apr 2, 2017 · 1 comment

Comments

@alexlamsl
Copy link
Collaborator

No --compress or --mangle is required to trigger this one:

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

for (var brake1 = 5; (c = c + 1) + (c = c + 1, 1 < []) >> NaN | "function" && 2 ^ Infinity && brake1 > 0; --brake1) {
    var brake2 = 5;
    do {
        {
            var brake3 = 5;
            while (/[abc4]/.test(("function" || b || 5).toString()) && --brake3 > 0) {
                for (var brake4 = 5; a-- && brake4 > 0; --brake4) {
                    switch (!function Object_6() {
                    }()) {
                      default:
                        a++ + (b |= a);
                        {
                            var brake9 = 5;
                            while ((c = c + 1) + /[abc4]/.test((--b || b || 5).toString()) && --brake9 > 0) {
                                var brake10 = 5;
                                do {
                                    var b_12 = --b + ("undefined" || a || 3).toString(), decodeURIComponent = /[abc4]/.test((--b + typeof (c = 1 + c,
                                    false !== -4 ^ "object" | 2 * -1 ^ [] >> (c = c + 1, 4)) || b || 5).toString());
                                } while ((a++ + 2 - /[a2][^e]+$/ ^ -3 >> "function" === -0 || 22 & "foo", "bar") && --brake10 > 0);
                            }
                        }

                      case -4 / 23..toString() << "undefined" >>> undefined > {} >= false << "undefined" >> 23..toString() > a++:
                        --b + /[abc4]/.test((a-- || b || 5).toString());
                        break;

                      case a++ + ((a++ + "function" === 0 * -4 & /[a2][^e]+$/ ^ (b_12 -= "undefined" << "undefined") % Infinity < "foo" ? b + 1 - .1 - .1 - .1 : (c = c + 1) + function parseFloat_14() {}()) || a || 3).toString():
                        break;

                      case /[abc4]/.test((a++ + typeof foo_15 === "number" || b || 5).toString()):
                        switch (true) {
                          case a++ + new function() {
                                "function" && 2 | [ , 0 ].length === 2, 4 >>> (b_12 === false <= 0 <= "function" & -2);
                                return Math;
                            }():
                            break;

                          case /[abc4]/.test((--b + a-- || b || 5).toString()):
                            break;

                          case 1 === 1 ? a : b:
                            break;

                          case typeof new function() {
                                return Math;
                            }():
                            a++ + NaN;
                            break;
                        }
                        for (var brake18 = 5; (c = c + 1) + ((/[abc4]/.test((/[abc4]/.test(((c = 1 + c,
                        23..toString() == -3 === (c = c + 1, "function") && [] >> -5 & NaN - ([ , 0 ].length === 2)) || b || 5).toString()) || b || 5).toString()) ? (c = c + 1) + typeof decodeURIComponent_19 : a++ + a--) || a || 3).toString() && brake18 > 0; --brake18) {
                            !function f0(decodeURIComponent_21) {
                                if (c = 1 + c, 25 == ([ , 0 ].length === 2) ^ 23..toString(), true != 25 == [] <= Infinity >>> -4) {
                                    c = 1 + c, {} && [ , 0 ][1] == 25 << -0 & Infinity / "function" % -3 * -0;
                                } else {
                                    c = 1 + c, (c = c + 1, -1) >= 4 / Infinity | (c = c + 1, 25), -0 >> Infinity;
                                }
                                var isNaN = (c = 1 + c, 0 + "number" === Infinity != false >>> [ , 0 ][1] - -2 >> -1 !== false), encodeURI_26 = (c = 1 + c,
                                -4 <= [ , 0 ][1] << (b_12 /= "foo" != -5) == undefined | [] && "object" & []);
                            }(/[abc4]/.test(((--b + (c = 1 + c, 0, "number" * [ , 0 ][1] - 25 + "function" | "undefined" | "foo" >>> false) ? (c = 1 + c,
                            4 - 23..toString() * NaN <= "object" > "foo" + [] ^ 22 != undefined) : (c = 1 + c,
                            0 - 25 ^ 3 + [ , 0 ][1] / 25 | 4 >= "undefined" <= {})) || b || 5).toString()));
                        }
                        break;
                    }
                }
            }
        }
    } while ((a++ + 1 === 1 ? a : b) && --brake2 > 0);
}

var decodeURI = a++ + (/[abc4]/.test(((c = c + 1) + (b %= a) || b || 5).toString()) || a || 3).toString();

console.log(null, a, b, c);


//-------------------------------------------------------------
// uglified code
// (beautified)
var a = 100, b = 10, c = 0;

for (var brake1 = 5; (c = c + 1) + (c = c + 1, 1 < []) >> NaN | "function" && 2 ^ Infinity && brake1 > 0; --brake1) {
    var brake2 = 5;
    do {
        {
            var brake3 = 5;
            while (/[abc4]/.test(("function" || b || 5).toString()) && --brake3 > 0) {
                for (var brake4 = 5; a-- && brake4 > 0; --brake4) {
                    switch (!function Object_6() {}()) {
                      default:
                        a++ + (b |= a);
                        {
                            var brake9 = 5;
                            while ((c = c + 1) + /[abc4]/.test((--b || b || 5).toString()) && --brake9 > 0) {
                                var brake10 = 5;
                                do {
                                    var b_12 = --b + ("undefined" || a || 3).toString(), decodeURIComponent = /[abc4]/.test((--b + typeof (c = 1 + c,
                                    false !== -4 ^ "object" | 2 * -1 ^ [] >> (c = c + 1, 4)) || b || 5).toString());
                                } while ((a++ + 2 - /[a2][^e]+$/ ^ -3 >> "function" === -0 || 22 & "foo", "bar") && --brake10 > 0);
                            }
                        }

                      case -4 / 23..toString() << "undefined" >>> undefined > {} >= false << "undefined" >> 23..toString() > a++:
                        --b + /[abc4]/.test((a-- || b || 5).toString());
                        break;

                      case a++ + ((a++ + "function" === 0 * -4 & /[a2][^e]+$/ ^ (b_12 -= "undefined" << "undefined") % Infinity < "foo" ? b + 1 - .1 - .1 - .1 : (c = c + 1) + function parseFloat_14() {}()) || a || 3).toString():
                        break;

                      case /[abc4]/.test((a++ + typeof foo_15 === "number" || b || 5).toString()):
                        switch (true) {
                          case a++ + new function() {
                                "function" && 2 | [ , 0 ].length === 2, 4 >>> (b_12 === false <= 0 <= "function" & -2);
                                return Math;
                            }():
                            break;

                          case /[abc4]/.test((--b + a-- || b || 5).toString()):
                            break;

                          case 1 === 1 ? a : b:
                            break;

                          case typeof new function() {
                                return Math;
                            }():
                            a++ + NaN;
                            break;
                        }
                        for (var brake18 = 5; (c = c + 1) + ((/[abc4]/.test((/[abc4]/.test(((c = 1 + c,
                        23..toString() == -3 === (c = c + 1, "function") && [] >> -5 & NaN - ([ , 0 ].length === 2)) || b || 5).toString()) || b || 5).toString()) ? (c = c + 1) + typeof decodeURIComponent_19 : a++ + a--) || a || 3).toString() && brake18 > 0; --brake18) {
                            !function f0(decodeURIComponent_21) {
                                if (c = 1 + c, 25 == ([ , 0 ].length === 2) ^ 23..toString(), true != 25 == [] <= Infinity >>> -4) {
                                    c = 1 + c, {} && [ , 0 ][1] == 25 << -0 & Infinity / "function" % -3 * -0;
                                } else {
                                    c = 1 + c, (c = c + 1, -1) >= 4 / Infinity | (c = c + 1, 25), -0 >> Infinity;
                                }
                                var isNaN = (c = 1 + c, 0 + "number" === Infinity != false >>> [ , 0 ][1] - -2 >> -1 !== false), encodeURI_26 = (c = 1 + c,
                                -4 <= [ , 0 ][1] << (b_12 /= "foo" != -5) == undefined | [] && "object" & []);
                            }(/[abc4]/.test(((--b + (c = 1 + c, 0, "number" * [ , 0 ][1] - 25 + "function" | "undefined" | "foo" >>> false) ? (c = 1 + c,
                            4 - 23..toString() * NaN <= "object" > "foo" + [] ^ 22 != undefined) : (c = 1 + c,
                            0 - 25 ^ 3 + [ , 0 ][1] / 25 | 4 >= "undefined" <= {})) || b || 5).toString()));
                        }
                        break;
                    }
                }
            }
        }
    } while ((a++ + 1 === 1 ? a : b) && --brake2 > 0);
}

var decodeURI = a++ + (/[abc4]/.test(((c = c + 1) + (b %= a) || b || 5).toString()) || a || 3).toString();

console.log(null, a, b, c);


original result:
null 6446 1603 23775

uglified result:
illegal access
minify(options):
{ compress: false,
  mangle: false,
  output: { beautify: true, bracketize: true },
  fromString: true }

Suspicious output options:
  screw_ie8
  semicolons
  shebang

Node.js 0.10 / Chakracore

$ bin/uglifyjs test.js -b | node
null 6446 1603 23775

Node.js 0.12

$ bin/uglifyjs test.js -b | node
[stdin]:73
var decodeURI = a++ + (/[abc4]/.test(((c = c + 1) + (b %= a) || b || 5).toStri
                    ^
illegal access

Node.js 4 / 6

$ bin/uglifyjs test.js -b | node
[stdin]:73
var decodeURI = a++ + (/[abc4]/.test(((c = c + 1) + (b %= a) || b || 5).toString()) || a || 3).toString();
                    ^
illegal access
@kzc
Copy link
Contributor

kzc commented Apr 2, 2017

Oddly, even though it appears to be a Node/V8 parser issue, the uglify -b output will run with node --turbo and its results will agree with non-V8 engines.

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

No branches or pull requests

2 participants