Change proc_exit to unwind the stack rather than exiting the host process. (#1646)
* Remove Cranelift's OutOfBounds trap, which is no longer used. * Change proc_exit to unwind instead of exit the host process. This implements the semantics in https://github.com/WebAssembly/WASI/pull/235. Fixes #783. Fixes #993. * Fix exit-status tests on Windows. * Revert the wiggle changes and re-introduce the wasi-common implementations. * Move `wasi_proc_exit` into the wasmtime-wasi crate. * Revert the spec_testsuite change. * Remove the old proc_exit implementations. * Make `TrapReason` an implementation detail. * Allow exit status 2 on Windows too. * Fix a documentation link. * Really fix a documentation link.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use wasmtime::Trap;
|
||||
|
||||
pub mod old;
|
||||
|
||||
pub use wasi_common::{WasiCtx, WasiCtxBuilder};
|
||||
@@ -12,3 +14,17 @@ pub fn is_wasi_module(name: &str) -> bool {
|
||||
// trick.
|
||||
name.starts_with("wasi")
|
||||
}
|
||||
|
||||
/// Implement the WASI `proc_exit` function. This function is implemented here
|
||||
/// instead of in wasi-common so that we can use the runtime to perform an
|
||||
/// unwind rather than exiting the host process.
|
||||
fn wasi_proc_exit(status: i32) -> Result<(), Trap> {
|
||||
// Check that the status is within WASI's range.
|
||||
if status >= 0 && status < 126 {
|
||||
Err(Trap::i32_exit(status))
|
||||
} else {
|
||||
Err(Trap::new(
|
||||
"exit with invalid exit status outside of [0..126)",
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user