Skip to content
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

JIT runtime failed to initiate panic #30

Open
dtolnay opened this issue Nov 5, 2019 · 3 comments
Open

JIT runtime failed to initiate panic #30

dtolnay opened this issue Nov 5, 2019 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@dtolnay
Copy link
Owner

dtolnay commented Nov 5, 2019

Panics seem to get printed decently by the interpreted runtime, but not the JIT runtime.

To reproduce, cherry-pick 149ca1a and then:

$ cargo build --release --target wasm32-unknown-unknown --manifest-path demo/impl/Cargo.toml && cargo run --manifest-path demo/caller/Cargo.toml

error: proc-macro derive panicked
 --> demo/caller/src/main.rs:3:10
  |
3 | #[derive(Demo)]
  |          ^^^^
  |
  = help: message: panicked at 'oh no!', src/lib.rs:5:5


$ cargo build --release --target wasm32-unknown-unknown --manifest-path demo/impl/Cargo.toml && WATT_JIT=/git/wasmtime/target/release/libwasmtime_api.so cargo run --manifest-path demo/caller/Cargo.toml

fatal runtime error: failed to initiate panic, error 5
error: could not compile `watt-demo-caller`.
@dtolnay dtolnay added the help wanted Extra attention is needed label Nov 5, 2019
@dtolnay
Copy link
Owner Author

dtolnay commented Nov 5, 2019

Is this because we are panicking across an FFI boundary?

@alexcrichton
Copy link
Collaborator

Ah yes this is a known issue with wasmtime. This is definitely related to the FFI boundary, but it's also related to JIT code generation in wasmtime.

I think the best strategy (for watt) is to ideally do something like:

  • Catch wasm panics with a custom hook
  • Tell the watt runtime what the panic message is
  • Force a trap to happen in wasm (let the wasm panic continue)
  • Catch the wasm trap in the caller
  • Look to see if a panic message was registered, and if so raise that panic. Otherwise raise an "abnormal trap" error for the wasm

That should avoid crossing any boundaries or dealing with JIT code and should work everywhere so long as wasm traps work everywhere.

@dtolnay
Copy link
Owner Author

dtolnay commented Nov 5, 2019

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants