diff --git a/crates/runtime/src/signalhandlers.rs b/crates/runtime/src/signalhandlers.rs index 5beb737769..97f27b9b42 100644 --- a/crates/runtime/src/signalhandlers.rs +++ b/crates/runtime/src/signalhandlers.rs @@ -61,6 +61,17 @@ pub extern "C" fn wasmtime_init_eager() { state.tried = true; assert!(!state.success); + // This is a really weird and unfortunate function call. For all the gory + // details see #829, but the tl;dr; is that in a trap handler we have 2 + // pages of stack space on Linux, and calling into libunwind which triggers + // the dynamic loader blows the stack. + // + // This is a dumb hack to work around this system-specific issue by + // capturing a backtrace once in the lifetime of a process to ensure that + // when we capture a backtrace in the trap handler all caches are primed, + // aka the dynamic loader has resolved all the relevant symbols. + drop(backtrace::Backtrace::new_unresolved()); + if unsafe { EnsureEagerSignalHandlers() == 0 } { return; }