diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ee3abd40a..00a7f15a070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C - [#2135](https://github.com/wasmerio/wasmer/pull/2135) [Documentation](./PACKAGING.md) for linux distribution maintainers ### Changed +- [#2299](https://github.com/wasmerio/wasmer/pull/2299) Unused trap codes (due to Wasm spec changes), `HeapSetterOutOfBounds` and `TableSetterOutOfBounds` were removed from `wasmer_vm::TrapCode` and the numbering of the remaining variants has been adjusted. - [#2293](https://github.com/wasmerio/wasmer/pull/2293) The `Memory::ty` trait method now returns `MemoryType` by value. `wasmer_vm::LinearMemory` now recomputes `MemoryType`'s `minimum` field when accessing its type. This behavior is what's expected by the latest spectests. `wasmer::Memory::ty` has also been updated to follow suit, it now returns `MemoryType` by value. - [#2251](https://github.com/wasmerio/wasmer/pull/2251) Wasmer CLI will now execute WASI modules with multiple WASI namespaces in them by default. Use `--allow-multiple-wasi-versions` to suppress the warning and use `--deny-multiple-wasi-versions` to make it an error. - [#2201](https://github.com/wasmerio/wasmer/pull/2201) Implement `loupe::MemoryUsage` for `wasmer::Instance`. diff --git a/lib/vm/src/table.rs b/lib/vm/src/table.rs index c4960abb540..80ddd656409 100644 --- a/lib/vm/src/table.rs +++ b/lib/vm/src/table.rs @@ -87,7 +87,7 @@ pub trait Table: fmt::Debug + Send + Sync + MemoryUsage { } if dst_index.checked_add(len).map_or(true, |m| m > self.size()) { - return Err(Trap::new_from_runtime(TrapCode::TableSetterOutOfBounds)); + return Err(Trap::new_from_runtime(TrapCode::TableAccessOutOfBounds)); } let srcs = src_index..src_index + len; diff --git a/lib/vm/src/trap/trapcode.rs b/lib/vm/src/trap/trapcode.rs index 985e14d08bd..953008c5d23 100644 --- a/lib/vm/src/trap/trapcode.rs +++ b/lib/vm/src/trap/trapcode.rs @@ -27,61 +27,49 @@ pub enum TrapCode { /// stack guard page. StackOverflow = 0, - /// Memory data doesn't fit the memory size. - /// - /// This only can happen during instantiation. - // TODO(bulk_memory): this is currently unused, if it's not used by the bulk - // memory spectests then we should remove it from Wasmer. - HeapSetterOutOfBounds = 1, - /// A `heap_addr` instruction detected an out-of-bounds error. /// /// Note that not all out-of-bounds heap accesses are reported this way; /// some are detected by a segmentation fault on the heap unmapped or /// offset-guard pages. - HeapAccessOutOfBounds = 2, + HeapAccessOutOfBounds = 1, /// A `heap_addr` instruction was misaligned. - HeapMisaligned = 3, - - /// Table Elements doesn't fit the table size. - /// - /// This only can happen during instantiation. - TableSetterOutOfBounds = 4, + HeapMisaligned = 2, /// A `table_addr` instruction detected an out-of-bounds error. - TableAccessOutOfBounds = 5, + TableAccessOutOfBounds = 3, /// Other bounds checking error. - OutOfBounds = 6, + OutOfBounds = 4, /// Indirect call to a null table entry. - IndirectCallToNull = 7, + IndirectCallToNull = 5, /// Signature mismatch on indirect call. - BadSignature = 8, + BadSignature = 6, /// An integer arithmetic operation caused an overflow. - IntegerOverflow = 9, + IntegerOverflow = 7, /// An integer division by zero. - IntegerDivisionByZero = 10, + IntegerDivisionByZero = 8, /// Failed float-to-int conversion. - BadConversionToInteger = 11, + BadConversionToInteger = 9, /// Code that was supposed to have been unreachable was reached. - UnreachableCodeReached = 12, + UnreachableCodeReached = 10, /// Execution has potentially run too long and may be interrupted. /// This trap is resumable. - Interrupt = 13, + Interrupt = 11, /// An atomic memory access was attempted with an unaligned pointer. - UnalignedAtomic = 14, + UnalignedAtomic = 12, /// A trap indicating that the runtime was unable to allocate sufficient memory. - VMOutOfMemory = 15, + VMOutOfMemory = 13, // /// A user-defined trap code. // User(u16), } @@ -91,12 +79,8 @@ impl TrapCode { pub fn message(&self) -> &str { match self { Self::StackOverflow => "call stack exhausted", - Self::HeapSetterOutOfBounds => "memory out of bounds: data segment does not fit", Self::HeapAccessOutOfBounds => "out of bounds memory access", Self::HeapMisaligned => "misaligned heap", - Self::TableSetterOutOfBounds => { - "out of bounds table access: elements segment does not fit" - } Self::TableAccessOutOfBounds => "undefined element: out of bounds table access", Self::OutOfBounds => "out of bounds", Self::IndirectCallToNull => "uninitialized element", @@ -117,10 +101,8 @@ impl Display for TrapCode { fn fmt(&self, f: &mut Formatter) -> fmt::Result { let identifier = match *self { Self::StackOverflow => "stk_ovf", - Self::HeapSetterOutOfBounds => "heap_set_oob", Self::HeapAccessOutOfBounds => "heap_get_oob", Self::HeapMisaligned => "heap_misaligned", - Self::TableSetterOutOfBounds => "table_set_oob", Self::TableAccessOutOfBounds => "table_get_oob", Self::OutOfBounds => "oob", Self::IndirectCallToNull => "icall_null", @@ -145,10 +127,8 @@ impl FromStr for TrapCode { use self::TrapCode::*; match s { "stk_ovf" => Ok(StackOverflow), - "heap_set_oob" => Ok(HeapSetterOutOfBounds), "heap_get_oob" => Ok(HeapAccessOutOfBounds), "heap_misaligned" => Ok(HeapMisaligned), - "table_set_oob" => Ok(TableSetterOutOfBounds), "table_get_oob" => Ok(TableAccessOutOfBounds), "oob" => Ok(OutOfBounds), "icall_null" => Ok(IndirectCallToNull), @@ -171,12 +151,10 @@ mod tests { use super::*; // Everything but user-defined codes. - const CODES: [TrapCode; 15] = [ + const CODES: [TrapCode; 13] = [ TrapCode::StackOverflow, - TrapCode::HeapSetterOutOfBounds, TrapCode::HeapAccessOutOfBounds, TrapCode::HeapMisaligned, - TrapCode::TableSetterOutOfBounds, TrapCode::TableAccessOutOfBounds, TrapCode::OutOfBounds, TrapCode::IndirectCallToNull,