Browse Source

Capture a backtrace before calling wasm (#830)

* Capture a backtrace before calling wasm

This helps mitigate the issue, at least locally, described in #829 and
there's some more comments inline in the code as well.

* Run rustfmt

* Move around where the trace happens
pull/834/head
Alex Crichton 5 years ago
committed by Dan Gohman
parent
commit
0c99ac3d7e
  1. 11
      crates/runtime/src/signalhandlers.rs

11
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;
}

Loading…
Cancel
Save