Skip to content

Double-panics recurse in panic = "abort" mode #97146

Open
@jamesmunns

Description

@jamesmunns

Today @diondokter noticed that in a no_std embedded binary, which is configured to use panic = "abort" as a default, a panic during the panic handler will recurse, rather than abort.

Here is an embedded reproduction case (you'd need an nRF52840-DK, but I've included the output in the README):

https://github.com/jamesmunns/multi-panic

The docs mention 'abort on double panic', but prior to this - I didn't realize this was unique to the "unwind" handler, rather than panics in general. This was a surprise to myself and a number of other experienced embedded-rust folks.

This was tested with stable rust 1.59, but I wanted to check (with the lang/libs teams?) whether this is:

  • Intended, and the docs (not sure exactly which ones) should be updated/clarified
  • Unintended, and this may need to be fixed

At this point, I'm also not sure if this generalizes to desktop programs in panic = "abort", but in that case, it may be a soundness issue if folks had not considered their panic handlers to be re-entrant safe (though that's probably just the std panic handler in almost every case anyway).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-no_stdArea: `#![no_std]`A-panicArea: Panicking machineryC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions