Restore wasmtime's default stack size limit to 1MB (#11993)

* Restore `wasmtime`'s default stack size limit to 1MB

* Add extra comments

* Enforce different maximum call depth in release mode

* Split the call depth limit in two
This commit is contained in:
Koute
2022-08-09 20:04:28 +09:00
committed by GitHub
parent d910386081
commit 9c56e79c43
2 changed files with 92 additions and 7 deletions
@@ -324,13 +324,19 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config,
.profiler(profiler)
.map_err(|e| WasmError::Instantiation(format!("fail to set profiler: {:#}", e)))?;
if let Some(DeterministicStackLimit { native_stack_max, .. }) =
semantics.deterministic_stack_limit
{
config
.max_wasm_stack(native_stack_max as usize)
.map_err(|e| WasmError::Other(format!("cannot set max wasm stack: {:#}", e)))?;
}
let native_stack_max = match semantics.deterministic_stack_limit {
Some(DeterministicStackLimit { native_stack_max, .. }) => native_stack_max,
// In `wasmtime` 0.35 the default stack size limit was changed from 1MB to 512KB.
//
// This broke at least one parachain which depended on the original 1MB limit,
// so here we restore it to what it was originally.
None => 1024 * 1024,
};
config
.max_wasm_stack(native_stack_max as usize)
.map_err(|e| WasmError::Other(format!("cannot set max wasm stack: {:#}", e)))?;
config.parallel_compilation(semantics.parallel_compilation);