diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index dbd5f47a71..b3c32f2bc6 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -365,8 +365,6 @@ impl Config { /// This option is `true` by default. /// /// [`WasmBacktrace`]: crate::WasmBacktrace - #[deprecated = "Backtraces will always be enabled in future Wasmtime releases; if this \ - causes problems for you, please file an issue."] pub fn wasm_backtrace(&mut self, enable: bool) -> &mut Self { self.wasm_backtrace = enable; self diff --git a/crates/wasmtime/src/trap.rs b/crates/wasmtime/src/trap.rs index 41b59fe0d4..e1e3fdd9ad 100644 --- a/crates/wasmtime/src/trap.rs +++ b/crates/wasmtime/src/trap.rs @@ -98,7 +98,9 @@ pub(crate) fn from_runtime_box( error, needs_backtrace, } => { - debug_assert!(needs_backtrace == backtrace.is_some()); + debug_assert!( + needs_backtrace == backtrace.is_some() || !store.engine().config().wasm_backtrace + ); (error, None) } wasmtime_runtime::TrapReason::Jit(pc) => { diff --git a/tests/all/traps.rs b/tests/all/traps.rs index a8005e1053..ae62280c6e 100644 --- a/tests/all/traps.rs +++ b/tests/all/traps.rs @@ -1160,3 +1160,28 @@ fn standalone_backtrace_disabled() -> Result<()> { f.call(&mut store, ())?; Ok(()) } + +#[test] +fn host_return_error_no_backtrace() -> Result<()> { + let mut config = Config::new(); + config.wasm_backtrace(false); + let engine = Engine::new(&config)?; + let mut store = Store::new(&engine, ()); + let module = Module::new( + &engine, + r#" + (module + (import "" "" (func $host)) + (func $foo (export "f") call $bar) + (func $bar call $host) + ) + "#, + )?; + let func = Func::wrap(&mut store, |_cx: Caller<'_, ()>| -> Result<()> { + bail!("test") + }); + let instance = Instance::new(&mut store, &module, &[func.into()])?; + let f = instance.get_typed_func::<(), ()>(&mut store, "f")?; + assert!(f.call(&mut store, ()).is_err()); + Ok(()) +}