bytecodealliance / ComponentizeJS

JS -> WebAssembly Component
Apache License 2.0
242 stars 32 forks source link

wasm `unreachable` instruction executed #74

Closed danieletorelli closed 8 months ago

danieletorelli commented 11 months ago

Hello, I'm encountering the error in the title when running a WASM file generated by Componentize and I'd need some help.

I created a small reproducer for you on my fork. You can find 3 branches:

All branches are building successfully with npm run build. The first two branches have ./test.sh pass successfully, while the third errors this way:

> test
> ./target/release/wasmtime-test

Error: error while executing at wasm backtrace:
    0: 0x57fc47 - <unknown>!<wasm function 6688>
    1: 0x5826bc - <unknown>!<wasm function 7282>
    2: 0x3306e9 - <unknown>!<wasm function 587>
    3: 0x57f97a - <unknown>!local:hello/hello#hello

Caused by:
    wasm trap: wasm `unreachable` instruction executed

Please note that the generated code between scala2 and scala3 branches might differ, but when imported manually it always works correctly:

> const { hello } = await import('./hello.js');
undefined
> hello.hello("Jane")
'Hello, Jane!'

This makes me wonder that something is wrong in the WASM file itself and that's why I'm reporting this issue. Please let me know if I can help you further.

squillace commented 10 months ago

this is interesting..... I get the same error in a completely different environment. I'll try to narrow down the repro....

guybedford commented 9 months ago

Sorry for the delayed response here. For ComponentizeJS, did you set enableStdout: true to get the error printed here?

guybedford commented 8 months ago

In the latest release of ComponentizeJS, logging is now disabled by default unless explicitly disabled. So errors will now display without needing an explicit enableStdout: true.

danieletorelli commented 8 months ago

Sorry for the delayed response here. For ComponentizeJS, did you set enableStdout: true to get the error printed here?

@guybedford Sorry as well for the delay. I tried both by explicitly enabling enableStdout and with the latest version, but the issue is not resolved. I'd ask you to reopen it, please.

Here the error, that again happens only with the scala3 branch of my fork while with scala2 and main branches everything works.

% npm run test 

> test
> ./target/release/wasmtime-test

source.js:785:3 TypeError: this is undefined
Redirecting call to abort() to mozalloc_abort

Error: error while executing at wasm backtrace:
    0: 0x769e66 - <unknown>!<wasm function 11234>
    1: 0x76d881 - <unknown>!<wasm function 11913>
    2: 0x3beb90 - <unknown>!<wasm function 682>
    3: 0x769df4 - <unknown>!local:hello/hello#hello

Caused by:
    wasm trap: wasm `unreachable` instruction executed

Please note that I also updated the fork branches against your latest main branch before testing again.