You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tl;dr there should be a panic build option to short-circuit runtime.runtimePanicAt to just unreachable 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_preview1fd_write being imported. My program does not print anything, and only imports unsafe.
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 the unsafe package like Slice or String can panic, but are also useful for passing memory between the guest and host.
flowchart TD
A[runtime.slicePanic] & B[runtime.nilPanic] --> C[runtime.runtimePanicAt]
C --> D[runtime.printstring] & E[runtime.putchar]
D --> E
E --> F[runtime.fd_write]
Loading
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.
Related to #3068, #2491.
tl;dr there should be a
panicbuild option to short-circuitruntime.runtimePanicAtto justunreachablevs. 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_preview1fd_writebeing 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 theunsafepackage likeSliceorStringcan 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_abortto 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.