-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Executing strace-grate causes stack pointer to override frame pointer causing an overflow:
lind-wasm/src/wasmtime/crates/wasmtime/src/runtime/vm/traphandlers/backtrace.rs
Lines 182 to 190 in 0de0b4e
| // At the start of each iteration of the loop, we know that `fp` is | |
| // a frame pointer from Wasm code. Therefore, we know it is not | |
| // being used as an extra general-purpose register, and it is safe | |
| // dereference to get the PC and the next older frame pointer. | |
| // The stack grows down, and therefore any frame pointer we are | |
| // dealing with should be less than the stack pointer on entry | |
| // to Wasm. | |
| assert!(trampoline_sp >= fp, "{trampoline_sp:#x} >= {fp:#x}"); |
During the initial triage issue appeared to be due to the large number of registered syscall handlers. Reducing the number of registered syscalls prevented the panic, which initially suggested stack size exhaustion issue.
Further debugging resulted that the root cause of the panics are syscalls that requires multi-threading: exec , exit, fork and clone. They can be interposed but forwarding them causes an unexpected behavior.
Building lind with the latest PR (that enables wasmtime backtrace) throws completely different errors and panics at:
thread 'lind-fork-2' (505124) panicked at /home/lind/lind-wasm/src/wasmtime/crates/fdtables/src/dashmaparrayglobal.rs:86:5:
Unknown cageid in fdtable access
thread 'lind-fork-2' (505124) panicked at /rustc/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/library/core/src/panicking.rs:225:5:
panic in a function that cannot unwind
The syscall invoked immediately before the panic is exit and associated cageid is 777777 which corresponds to RawPOSIX.
Additionally, the output produced by the grate is non-deterministic and might be due #774.
This issue can be reproduced by executing strace-grate with any test in our test suite.