Repository navigation
Description
Version of emscripten/emsdk:
3.1.50 (047b825)
The following exception is thrown when compiling code with -O2 or higher.
/home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:25
throw new Error(text);
^
Error
at assert (/home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:25:11)
at /home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:430:13
at Array.forEach (<anonymous>)
at Object.VariableDeclarator (/home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:429:23)
at c (/home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:85:20)
at recursiveWalk (/home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:87:5)
at /home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:83:38
at maybeChild (/home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:47:7)
at Array.forEach (<anonymous>)
at visitChildren (/home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js:57:15)
em++: error: '/home/wolf/emsdk/node/16.20.0_64bit/bin/node /home/wolf/emsdk/upstream/emscripten/tools/acorn-optimizer.js /tmp/emscripten_temp_ctpxdg9v/x.release.jso1.js AJSDCE minifyWhitespace -o /tmp/emscripten_temp_ctpxdg9v/x.release.jso2.js' failed (returned 1)
emscripten/tools/acorn-optimizer.js
Lines 428 to 433 in 047b825
| } else if (id.type === 'ArrayPattern') { | |
| id.elements.forEach((node) => { | |
| assert(node.type === 'Identifier'); | |
| const name = node.name; | |
| ensureData(scopes[scopes.length - 1], name).def = 1; | |
| }); |
The node.type in the failing case is ObjectPattern.
Metadata
Metadata
Assignees
Labels
No labels
Activity
sbc100 commentedon Dec 1, 2023
Thanks for the report @wolfpld. Is this a new issue that just started happening for you? (i.e. did it work with the same code in previous versions of emscripten?)
Do you happen for know what code is causing this in the input? If possible perhaps you could attach the JS file that is causing the issue? (You can use EMCC_DEBUG_SAVE=1 to have the js file saved).
wolfpld commentedon Dec 1, 2023
The problem started to appear after integrating the Agora Video Streaming SDK (https://www.agora.io/en/) into the existing code. I also examined emscripten 3.1.48 and 3.1.47 and these versions also have issues in
acorn-optimizer.js. There have been some fixes to the optimizer, eg #20639, so I did not look too closely at those old versions, as the code has changed anyway.At the moment I do not have a minimal reproducible example that would show the problem. FWIW, the emscripten-generated code is optimized without problems. It is likely that the Agora SDK javascript code uses some unusual language syntax that the minimizer has trouble parsing.
wolfpld commentedon Dec 4, 2023
The issue is not present in 3.1.35.
wolfpld commentedon Dec 4, 2023
To reproduce the issue create the following files:
a.cpp:package.json:{ "devDependencies": { "agora-rtc-sdk-ng" : "4.19.0", "webpack": "^5.74.0", "webpack-cli": "^4.10.0" } }webpack.config.js:index.js:Then run the following commands:
sbc100 commentedon Dec 4, 2023
Is there any chance you could attach the resulting
all.js?wolfpld commentedon Dec 4, 2023
all.js.gz
Add line filename and line number information to acorn-optimizer errors
Fix parsing of nested object patterns in acorn-optimizer.js
Add line filename and line number information to acorn-optimizer errors
Add line filename and line number information to acorn-optimizer errors
Fix parsing of nested object patterns in acorn-optimizer.js
Add line filename and line number information to acorn-optimizer errors
Fix parsing of nested object patterns in acorn-optimizer.js
Add line filename and line number information to acorn-optimizer errors
Add line filename and line number information to acorn-optimizer errors
Add line filename and line number information to acorn-optimizer errors
Add line filename and line number information to acorn-optimizer erro…
Fix parsing of nested object patterns in acorn-optimizer.js
Fix parsing of nested object patterns in acorn-optimizer.js
Fix parsing of nested object patterns in acorn-optimizer.js
Fix parsing of nested object patterns in acorn-optimizer.js (#20835)
wolfpld commentedon Dec 5, 2023
I have checked with 3.1.51-git (fb0d986) and I am now getting:
Same repro.
Fix js-optimizer crash on empty array destructuring element
sbc100 commentedon Dec 5, 2023
Followup fix in #20843.
I verified that your
all.jscan now run through our acorn pass.Fix js-optimizer crash on empty array destructuring element
Fix js-optimizer crash on empty array destructuring element (#20843)
wolfpld commentedon Dec 6, 2023
Confirming that it works now. Thanks!