emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.36k stars 3.25k forks source link

Internal compiler error in src/compiler.js #20107

Open goldwaving opened 10 months ago

goldwaving commented 10 months ago

Emscripten v3.1.44 on Windows 11.

Internal compiler error in src/compiler.js!
Please create a bug report at https://github.com/emscripten-core/emscripten/issues/
with a log of the build and the input files used to run. Exception message: "TypeError: sig.slice(...).replace is not a function
   at addFromLibrary (C:\Develop\emsdk-main\upstream\emscripten\src\jsifier.js:528:57)
   at symbolHandler (C:\Develop\emsdk-main\upstream\emscripten\src\jsifier.js:554:16)
   at symbolHandler (C:\Develop\emsdk-main\upstream\emscripten\src\jsifier.js:554:16)
   at Object.<anonymous> (C:\Develop\emsdk-main\upstream\emscripten\src\compiler.js:102:3
   at Module._compile (node:internal/modules/cjs/loader:1196:14)
   at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
   at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
   at Function.Module._load (node:internal/modules/cjs/loader:909:12)
   at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
   at node:internal/main/run_main_module:22:47

Maybe check length of sig is greater than 1 character?

sbc100 commented 10 months ago

Hmm.. but sig.slice(1) should always return a string even if sig is the empty string.

> ''.slice(1).replace(/j/g, 'ii')
''

Which leads me to believe that perhaps sig is perhaps some other type? Can add console.log(sig) and console.log(typeof sig) return before line 528 of jsifier.js?

sbc100 commented 10 months ago

Are you passing your own JS library files? (i.e. are you using --js-library?). Can you share your full link command?

goldwaving commented 10 months ago

Good catch. Turns out that one of my sigs was ['iiii'] instead of just 'iiii'. Perhaps there could be a check that sig is a string somewhere to avoid this kind of a compiler error.

sbc100 commented 10 months ago

Sounds like a good idea.