-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)Area: Debugging information in compiled programs (DWARF, PDB, etc.)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
As a coder
Given I have a fn main() { main() }
Then I expect the following output:
Exception in thread "main" java.lang.StackOverflowError
at X.main(X.java:3)
at X.main(X.java:3)
at X.main(X.java:3)
at X.main(X.java:3)
Obviously this is an example of how Java handles stack overflows, but you get the idea.
There didn't seem to be a tracking issue for this, so here is one.
(Some discussion here: https://users.rust-lang.org/t/how-to-diagnose-a-stack-overflow-issues-cause/17320/9 )
I've had a little look and I naively think we need to do something like this in sys_common/util.rs
#[allow(dead_code)] // stack overflow detection not enabled on all platforms
pub unsafe fn report_overflow() {
dumb_print(format_args!("\nthread '{}' has overflowed its stack\n",
thread::current().name().unwrap_or("<unknown>")));
#[cfg(feature = "backtrace")]
{
let log_backtrace = backtrace::log_enabled();
use sync::atomic::{AtomicBool, Ordering};
static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
if let Some(format) = log_backtrace {
if let Ok(mut stderr) = Stderr::new() {
let _ = backtrace::print(&mut stderr, format);
}
} else if FIRST_PANIC.compare_and_swap(true, false, Ordering::SeqCst) {
dumb_print(format_args!("note: Run with `RUST_BACKTRACE=1` for a backtrace."));
}
}
}
Quite possibly one can ditch the first panic checks. I'm sure there's lots of concerns here, e.g. have we got enough stack headroom to report without going pop.
dbdr, sirgl, let4be, viluon, kaleidawave and 15 moreaknuds1, queer and kands-codeLamGC
Metadata
Metadata
Assignees
Labels
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)Area: Debugging information in compiled programs (DWARF, PDB, etc.)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.