Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document panic-in-panic ("double panic") behavior #1712

Open
ehuss opened this issue Jan 13, 2025 · 1 comment
Open

Document panic-in-panic ("double panic") behavior #1712

ehuss opened this issue Jan 13, 2025 · 1 comment
Labels
A-panic Area: Panics

Comments

@ehuss
Copy link
Contributor

ehuss commented Jan 13, 2025

I can't find any documentation about double panic behavior (other than https://doc.rust-lang.org/std/ops/trait.Drop.html#panics, which currently just says "will likely abort the program"). There are some subtleties about this, because some handlers will cause a hang (see rust-lang/rust#97146).

I'm not sure exactly where or how to document this. Some thoughts:

@ehuss ehuss added the A-panic Area: Panics label Jan 13, 2025
@chorman0773
Copy link
Contributor

Note that the behaviour of the default (in rustc libstd) panic handler is interesting here, and I don't know how much of that is stable or implementation detail:

  • On the first panic, it runs the panic hook, then executes the default action depending on the runtime - unwind or abort,
  • On the second panic, it enters the panic hook as well (which can cause it to reenter if it was the panic hook, rather than a destructor, that panicked for a second time), then aborts immediately.
  • If a panic happens for the third time, it just instantly aborts the process without running the panic hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: Panics
Projects
None yet
Development

No branches or pull requests

2 participants