Add a limits and trap-on-OOM options to the CLI (#6149)
* Add a limits and trap-on-OOM options to the CLI This commit adds new options to the `wasmtime` CLI to control the `Store::limiter` behavior at runtime. This enables artificially restriction the memory usage of the wasm instance, for example. Additionally a new option is added to `StoreLimits` to force a trap on growth failure. This is intended to help quickly debug modules with backtraces if OOM is happening, or even diagnosing if OOM is happening in the first place. * Fix compile of fuzzing oracle
This commit is contained in:
@@ -97,13 +97,18 @@ impl StoreLimits {
|
||||
}
|
||||
|
||||
impl ResourceLimiter for StoreLimits {
|
||||
fn memory_growing(&mut self, current: usize, desired: usize, _maximum: Option<usize>) -> bool {
|
||||
self.alloc(desired - current)
|
||||
fn memory_growing(
|
||||
&mut self,
|
||||
current: usize,
|
||||
desired: usize,
|
||||
_maximum: Option<usize>,
|
||||
) -> Result<bool> {
|
||||
Ok(self.alloc(desired - current))
|
||||
}
|
||||
|
||||
fn table_growing(&mut self, current: u32, desired: u32, _maximum: Option<u32>) -> bool {
|
||||
fn table_growing(&mut self, current: u32, desired: u32, _maximum: Option<u32>) -> Result<bool> {
|
||||
let delta = (desired - current) as usize * std::mem::size_of::<usize>();
|
||||
self.alloc(delta)
|
||||
Ok(self.alloc(delta))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user