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.