This new option determines whether to terminate the guest with a new TerminationDetails::HeapOutOfMemory variant when memory.grow fails, rather than returning -1. It is disabled by default, but can be set via InstanceBuilder or directly on the Instance.
This behavior deviates from the WebAssembly spec, but is useful in practice for determining when guest programs fail due to an exhausted heap.
Most languages will compile to code that includes an unreachable instruction if allocation fails, but this same instruction might also appear when other types of assertions fail, panic!() is called, etc. Terminating allows the error to be more directly identifiable.
This new option determines whether to terminate the guest with a new
TerminationDetails::HeapOutOfMemory
variant whenmemory.grow
fails, rather than returning-1
. It is disabled by default, but can be set viaInstanceBuilder
or directly on theInstance
.This behavior deviates from the WebAssembly spec, but is useful in practice for determining when guest programs fail due to an exhausted heap.
Most languages will compile to code that includes an
unreachable
instruction if allocation fails, but this same instruction might also appear when other types of assertions fail,panic!()
is called, etc. Terminating allows the error to be more directly identifiable.