-
Notifications
You must be signed in to change notification settings - Fork 935
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
-panic=trap
still prints panic messages
#4161
Comments
The bug here is that TinyGo still calls |
-panic=trap
still prints panic messages
aykevl
added a commit
that referenced
this issue
Mar 16, 2024
Support for `-panic=trap` was previously a pass in the optimization pipeline. This change moves it to the compiler and runtime, which in my opinion is a much better place. As a side effect, it also fixes #4161 by trapping inside runtime.runtimePanicAt and not just runtime.runtimePanic. This change also adds a test for the list of imported functions. This is a more generic test where it's easy to add more tests for WebAssembly file properties, such as exported functions.
Here is a fix: #4195 |
deadprogram
pushed a commit
that referenced
this issue
Mar 19, 2024
Support for `-panic=trap` was previously a pass in the optimization pipeline. This change moves it to the compiler and runtime, which in my opinion is a much better place. As a side effect, it also fixes #4161 by trapping inside runtime.runtimePanicAt and not just runtime.runtimePanic. This change also adds a test for the list of imported functions. This is a more generic test where it's easy to add more tests for WebAssembly file properties, such as exported functions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related to #3068, #2491.
tl;dr there should be a
panic
build option to short-circuitruntime.runtimePanicAt
to justunreachable
vs. printing a string.I was trying to produce a WASM progra, that could accept & return a string from/to the host, similar to this wazero example.
I compiled with tinygo v0.30.0,
tinygo build -o main.wasm -no-debug -panic=trap -scheduler=none -gc=leaking -target=wasm main.go
.Inspecting the output with wasmer, I found
wasi_snapshot_preview1
fd_write
being imported. My program does not print anything, and only importsunsafe
.Converting the WASM to WAT, I found that the runtime will unconditionally try to print during a
runtimePanic
. This feels pretty unavoidable, as funcs in theunsafe
package likeSlice
orString
can panic, but are also useful for passing memory between the guest and host.Relevant WAT snippet:
Call graph:
Rust has the build option
panic_immediate_abort
to omit any string formatting on panic, for similar reasons of small code size & minimal dependencies. Adding something similar to TinyGo would allow for WASM programs that include the runtime without also requiring a WASI-compliant host.The text was updated successfully, but these errors were encountered: