dtolnay / watt

Runtime for executing procedural macros as WebAssembly
Apache License 2.0
1.29k stars 29 forks source link

JIT runtime failed to initiate panic #30

Open dtolnay opened 5 years ago

dtolnay commented 5 years ago

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

To reproduce, cherry-pick 149ca1a421e461ecb1f88cb1b37fcceb9dd6b653 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 commented 5 years ago

Is this because we are panicking across an FFI boundary?

alexcrichton commented 5 years ago

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:

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

dtolnay commented 5 years ago

Sounds good!