pub enum TrapCode {
UnreachableCodeReached,
MemoryOutOfBounds,
TableOutOfBounds,
IndirectCallToNull,
IntegerDivisionByZero,
IntegerOverflow,
BadConversionToInteger,
StackOverflow,
BadSignature,
OutOfFuel,
GrowthOperationLimited,
}
Expand description
Error type which can be thrown by wasm code or by host environment.
See Trap
for details.
Variants§
UnreachableCodeReached
Wasm code executed unreachable
opcode.
This indicates that unreachable Wasm code was actually reached.
This opcode have a similar purpose as ud2
in x86.
MemoryOutOfBounds
Attempt to load or store at the address which lies outside of bounds of the memory.
Since addresses are interpreted as unsigned integers, out of bounds access can’t happen with negative addresses (i.e. they will always wrap).
TableOutOfBounds
Attempt to access table element at index which lies outside of bounds.
This typically can happen when call_indirect
is executed
with index that lies out of bounds.
Since indexes are interpreted as unsigned integers, out of bounds access can’t happen with negative indexes (i.e. they will always wrap).
IndirectCallToNull
Indicates that a call_indirect
instruction called a function at
an uninitialized (i.e. null
) table index.
IntegerDivisionByZero
Attempt to divide by zero.
This trap typically can happen if div
or rem
is executed with
zero as divider.
IntegerOverflow
An integer arithmetic operation caused an overflow.
This can happen when trying to do signed division (or get the remainder) -2N-1 over -1. This is because the result +2N-1 isn’t representable as a N-bit signed integer.
BadConversionToInteger
Attempted to make an invalid conversion to an integer type.
This can for example happen when trying to truncate NaNs, infinity, or value for which the result is out of range into an integer.
StackOverflow
Stack overflow.
This is likely caused by some infinite or very deep recursion. Extensive inlining might also be the cause of stack overflow.
BadSignature
Attempt to invoke a function with mismatching signature.
This can happen with indirect calls as they always specify the expected signature of function. If an indirect call is executed with an index that points to a function with signature different of what is expected by this indirect call, this trap is raised.
OutOfFuel
This trap is raised when a WebAssembly execution ran out of fuel.
The Wasmi execution engine can be configured to instrument its internal bytecode so that fuel is consumed for each executed instruction. This is useful to deterministically halt or yield a WebAssembly execution.
GrowthOperationLimited
This trap is raised when a growth operation was attempted and an
installed wasmi::ResourceLimiter
returned Err(...)
from the
associated table_growing
or memory_growing
method, indicating a
desire on the part of the embedder to trap the interpreter rather than
merely fail the growth operation.
Implementations§
Trait Implementations§
impl Copy for TrapCode
impl Eq for TrapCode
impl StructuralPartialEq for TrapCode
Auto Trait Implementations§
impl Freeze for TrapCode
impl RefUnwindSafe for TrapCode
impl Send for TrapCode
impl Sync for TrapCode
impl Unpin for TrapCode
impl UnwindSafe for TrapCode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.