Rollup merge of #122847 - workingjubilee:suggest-rust-min-stack-workaround-on-overflow, r=TaKO8Ki
Suggest `RUST_MIN_STACK` workaround on overflow For some Rust crates, like p384, we can't do a whole lot about it even if the stack overflow is reported like in rust-lang/rust#122357 because the problem may be inside LLVM or another codegen backend. We can, however, suggest people set a new `RUST_MIN_STACK` value while handling the SIGSEGV, as that stack-setting will carry forward into the dylib. As a bonus, this also leads to cleaning up the stack-setting code a bit.
This commit is contained in:
commit
b317cda7ea
2 changed files with 22 additions and 15 deletions
|
@ -1,6 +1,7 @@
|
|||
//! Signal handler for rustc
|
||||
//! Primarily used to extract a backtrace from stack overflow
|
||||
|
||||
use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE};
|
||||
use std::alloc::{alloc, Layout};
|
||||
use std::{fmt, mem, ptr};
|
||||
|
||||
|
@ -100,7 +101,10 @@ extern "C" fn print_stack_trace(_: libc::c_int) {
|
|||
written += 1;
|
||||
}
|
||||
raw_errln!("note: we would appreciate a report at https://github.com/rust-lang/rust");
|
||||
written += 1;
|
||||
// get the current stack size WITHOUT blocking and double it
|
||||
let new_size = STACK_SIZE.get().copied().unwrap_or(DEFAULT_STACK_SIZE) * 2;
|
||||
raw_errln!("help: you can increase rustc's stack size by setting RUST_MIN_STACK={new_size}");
|
||||
written += 2;
|
||||
if written > 24 {
|
||||
// We probably just scrolled the earlier "we got SIGSEGV" message off the terminal
|
||||
raw_errln!("note: backtrace dumped due to SIGSEGV! resuming signal");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue