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:
@@ -27,9 +27,6 @@ pub enum TrapCode {
|
||||
/// A `table_addr` instruction detected an out-of-bounds error.
|
||||
TableOutOfBounds,
|
||||
|
||||
/// Other bounds checking error.
|
||||
OutOfBounds,
|
||||
|
||||
/// Indirect call to a null table entry.
|
||||
IndirectCallToNull,
|
||||
|
||||
@@ -63,7 +60,6 @@ impl Display for TrapCode {
|
||||
StackOverflow => "stk_ovf",
|
||||
HeapOutOfBounds => "heap_oob",
|
||||
TableOutOfBounds => "table_oob",
|
||||
OutOfBounds => "oob",
|
||||
IndirectCallToNull => "icall_null",
|
||||
BadSignature => "bad_sig",
|
||||
IntegerOverflow => "int_ovf",
|
||||
@@ -86,7 +82,6 @@ impl FromStr for TrapCode {
|
||||
"stk_ovf" => Ok(StackOverflow),
|
||||
"heap_oob" => Ok(HeapOutOfBounds),
|
||||
"table_oob" => Ok(TableOutOfBounds),
|
||||
"oob" => Ok(OutOfBounds),
|
||||
"icall_null" => Ok(IndirectCallToNull),
|
||||
"bad_sig" => Ok(BadSignature),
|
||||
"int_ovf" => Ok(IntegerOverflow),
|
||||
@@ -106,11 +101,10 @@ mod tests {
|
||||
use alloc::string::ToString;
|
||||
|
||||
// Everything but user-defined codes.
|
||||
const CODES: [TrapCode; 11] = [
|
||||
const CODES: [TrapCode; 10] = [
|
||||
TrapCode::StackOverflow,
|
||||
TrapCode::HeapOutOfBounds,
|
||||
TrapCode::TableOutOfBounds,
|
||||
TrapCode::OutOfBounds,
|
||||
TrapCode::IndirectCallToNull,
|
||||
TrapCode::BadSignature,
|
||||
TrapCode::IntegerOverflow,
|
||||
|
||||
@@ -25,7 +25,7 @@ block201:
|
||||
return
|
||||
|
||||
block202:
|
||||
trap oob
|
||||
trap heap_oob
|
||||
}
|
||||
; check: v1 = ifcmp_imm v0, 17
|
||||
; check: brif eq v1, block201
|
||||
@@ -56,7 +56,7 @@ block201:
|
||||
return
|
||||
|
||||
block202:
|
||||
trap oob
|
||||
trap heap_oob
|
||||
}
|
||||
; check: v2 = ffcmp v0, v1
|
||||
; check: brff eq v2, block201
|
||||
|
||||
@@ -223,7 +223,7 @@ function %cond_traps(i32) {
|
||||
block0(v0: i32):
|
||||
trapz v0, stk_ovf
|
||||
v1 = ifcmp_imm v0, 5
|
||||
trapif ugt v1, oob
|
||||
trapif ugt v1, heap_oob
|
||||
v2 = bitcast.f32 v1
|
||||
v3 = ffcmp v2, v2
|
||||
trapff uno v3, int_ovf
|
||||
@@ -233,7 +233,7 @@ block0(v0: i32):
|
||||
; nextln: block0(v0: i32):
|
||||
; nextln: trapz v0, stk_ovf
|
||||
; nextln: v1 = ifcmp_imm v0, 5
|
||||
; nextln: trapif ugt v1, oob
|
||||
; nextln: trapif ugt v1, heap_oob
|
||||
; nextln: v2 = bitcast.f32 v1
|
||||
; nextln: v3 = ffcmp v2, v2
|
||||
; nextln: trapff uno v3, int_ovf
|
||||
|
||||
@@ -139,7 +139,7 @@ block0(v0: i64):
|
||||
jump block4
|
||||
|
||||
block4:
|
||||
trap oob
|
||||
trap heap_oob
|
||||
|
||||
block2:
|
||||
v8 = load.i64 v5+8
|
||||
|
||||
@@ -54,7 +54,7 @@ block0(v0: i32):
|
||||
br_table v0, block4, jt0
|
||||
|
||||
block4:
|
||||
trap oob
|
||||
trap heap_oob
|
||||
|
||||
block1:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user