Skip to content

Commit

Permalink
Increase the sigaltstack stack size (bytecodealliance#4964)
Browse files Browse the repository at this point in the history
This commit updates the `MIN_STACK_SIZE` constant for Unix platforms
when allocating a sigaltstack from 16k to 64k. The signal handler
captures a wasm `Backtrace` which involves memory allocations and it was
recently discovered that, at least in debug mode, jemalloc can take up
to 16k of stack space for an allocation. To allow running the
sigaltstack size is increased here.
  • Loading branch information
alexcrichton authored Sep 26, 2022
1 parent f12ef84 commit 8499420
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/runtime/src/traphandlers/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,14 @@ pub fn lazy_per_thread_init() {

/// The size of the sigaltstack (not including the guard, which will be
/// added). Make this large enough to run our signal handlers.
const MIN_STACK_SIZE: usize = 16 * 4096;
///
/// The main current requirement of the signal handler in terms of stack
/// space is that `malloc`/`realloc` are called to create a `Backtrace` of
/// wasm frames.
///
/// Historically this was 16k. Turns out jemalloc requires more than 16k of
/// stack space in debug mode, so this was bumped to 64k.
const MIN_STACK_SIZE: usize = 64 * 4096;

struct Stack {
mmap_ptr: *mut libc::c_void,
Expand Down

0 comments on commit 8499420

Please sign in to comment.