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

Closed
alexlamsl opened this issue Sep 3, 2022 · 0 comments · Fixed by #5642
Closed

ufuzz failure #5641

alexlamsl opened this issue Sep 3, 2022 · 0 comments · Fixed by #5642
Labels

Comments

@alexlamsl
Copy link
Collaborator

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

function f0() {
    c = c + 1;
    if (1 === 1 ? a : b) {
        try {
            {
                b = a;
                var b = b && b.done;
            }
        } finally {}
    } else {
        var b_1 = 1 === 1 ? a : b;
    }
}

var undefined_1 = f0((c = c + 1) + delete ((("object" || -3) ^ [ , 0 ][1] % 5) + (-3 == -4 ?? (a && (a[c = 1 + c, 
(24..toString() << [ , 0 ][1]) * ({} ^ undefined) === ("c" <= "undefined" || a && (a[c = 1 + c, 
5 % this > ("foo" < 22) || -0 >>> "b" ^ (c = c + 1, false)] = true ^ this))] = 0 ^ 23..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 b;
    c += 1, a && b.done;
}

var undefined_1 = f0((c += 1) + !0, {});

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

uglified result:
evalmachine.<anonymous>:1
var _calls_=10,a=100,b=10,c=0;function f0(){var b;c+=1,a&&b.done}var undefined_1=f0((c+=1)+!0,{});console.log(null,a,b,c,1/0,NaN,void 0);
                                                            ^

TypeError: Cannot read properties of undefined (reading 'done')
    at f0 (evalmachine.<anonymous>:1:61)
    at evalmachine.<anonymous>:1:82
    at Script.runInContext (node:vm:141:12)
    at Object.runInContext (node:vm:297:6)
    at run_code_vm (/Users/runner/work/UglifyJS/UglifyJS/test/sandbox.js:266:12)
    at Object.exports.run_code (/Users/runner/work/UglifyJS/UglifyJS/test/sandbox.js:39:16)
    at run_code (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2122:20)
    at /Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2569:29
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2556:20)
// reduced test case (output will differ)

// (beautified)
var a = 1;

function f0() {
    if (a) {
        b = 1;
        var b = b && b.done;
    } else {
        var b_1 = 1 ? a : b;
    }
}

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

Suspicious compress options:
  collapse_vars
  conditionals
  dead_code
  side_effects
@alexlamsl alexlamsl added the bug label Sep 3, 2022
alexlamsl added a commit to alexlamsl/UglifyJS that referenced this issue Sep 3, 2022
alexlamsl added a commit that referenced this issue Sep 3, 2022
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