Panic while formatting panic message + always_abort leads to stack overflow
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Example and initial analysis by @correabuscar:
#![feature(panic_always_abort)]
use std::fmt::{Display, self};
struct MyStruct;
impl Display for MyStruct {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
panic!("this is bad: {}", MyStruct);
}
}
fn main() {
std::panic::always_abort();
println!("{}", MyStruct);
}
The reason for this is that if both "panic while processing panic" and "panic after always_abort" apply, then we use the AlwaysAbort code path which does format the panic message.
This could be fixed by moving this check further down below the in_panic_hook check:
But I don't know if this has other adverse side-effects. Can we even access thread-local variables after fork (i.e., when always-abort is set)?
Cc @Amanieu
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust example in the issue and inspect library/std/src/panicking.rs around lines 393-395, especially the AlwaysAbort and in_panic_hook checks. Reproduce the stack overflow, then determine whether moving the check avoids formatting during panic processing without adverse effects, including after fork and when accessing thread-local state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100