bytecodealliance / bytecodealliance/wasmtime
Call `memory_grow_failed` hook for custom `ResourceLimiter`s
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
#### Feature
Call `memory_grow_failed` hook for custom `ResourceLimiter`s.
#### Benefit
Currently, although a `ResourceLimiter` can prevent further memory growth, it is not notified of an error. The error returned from `call` methods on `Linker` for example is about reaching unreachable code(???) in this case.
#### Implementation
Turn this: https://github.com/bytecodealliance/wasmtime/blob/3dbdcfa220df1406b3627772194eff859104e17a/crates/runtime/src/memory.rs#L568-L571
into this:
```rust
// Store limiter gets first chance to reject memory_growing.
if !store.memory_growing(old_byte_size, new_byte_size, maximum)? {
store.memory_grow_failed(&format_err!("Memory maximum size exceeded"));
return Ok(None);
}
```
#### Alternatives
Contributor guide
Assessment
This issue has not been assessed yet.