Skip to content

catch_unwind panics due to failing debug assert when used during unwinding #68696

Closed
@tmiasko

Description

@tmiasko

In particular catch_unwind panics because of failing assert in

debug_assert!(update_panic_count(0) == 0);

For example:

struct Catch;

impl Drop for Catch {
    fn drop(&mut self) {
        let _ = std::panic::catch_unwind(|| {});
    }
}

#[test]
#[should_panic]
fn it_works() {
    let catch = Catch;
    panic!("ups");
}
$ cargo test -Zbuild-std --target x86_64-unknown-linux-gnu
   Compiling panic v0.1.0 (/.../panic)
    Finished test [unoptimized + debuginfo] target(s) in 1.06s
     Running target/x86_64-unknown-linux-gnu/debug/deps/panic-118296df2d538b47

running 1 test
thread panicked while panicking. aborting.
error: test failed, to rerun pass '--lib'

Caused by:
  process didn't exit successfully: `/.../target/x86_64-unknown-linux-gnu/debug/deps/panic-118296df2d538b47` (signal: 4, SIGILL: illegal instruction)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.T-libs-apiRelevant to the library API 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