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

Panics with cranelift on MacOS cause "fatal runtime error: failed to initiate panic, error 5" #1527

Open
lucasmerlin opened this issue Aug 16, 2024 · 3 comments
Labels
A-unwind Area: Unwinding

Comments

@lucasmerlin
Copy link

lucasmerlin commented Aug 16, 2024

Having a failing assert (e.g. assert_eq!(1, 2);) or a panic somewhere causes fatal runtime error: failed to initiate panic, error 5 when executing with the cranelift codegen enabled.

I'm using:

  • MacOS 14.5
  • cargo 1.82.0-nightly (2f738d617 2024-08-13) (Same thing also happened with 2024-08-05)

I also made a small reproduciton:
https://github.com/lucasmerlin/test_error_repro

Running cargo test outputs:

cargo test
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/main.rs (target/debug/deps/test_error_repro-03985647548e948b)

running 1 test
fatal runtime error: failed to initiate panic, error 5
error: test failed, to rerun pass `--bin test_error_repro`

Caused by:
  process didn't exit successfully: `/Users/lucasprivat/RustroverProjects/test_error_repro/target/debug/deps/test_error_repro-03985647548e948b` (signal: 6, SIGABRT: process abort signal)

Running cargo run outputs:

cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/test_error_repro`
thread 'main' panicked at src/main.rs:2:3:
assertion `left == right` failed
  left: 1
 right: 2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
zsh: abort      cargo run

Interestingly, the assert message is printed when running with cargo run and not when running cargo test (which is a bit annoying because it makes it difficult to figure out why the test is failing)

Maybe related to rust-lang/rust#88622

@bjorn3
Copy link
Member

bjorn3 commented Aug 16, 2024

This is because panic=unwind isn't supported yet. For getting cargo test to print the panic message you need to pass -Cpanic=abort -Zpanic-abort-tests to rustc when compiling. For example using RUSTFLAGS. This will cause the test harness to run every test in a subprocess, such that a panic doesn't abort the entire test process and the test harness has a chance to print the test failure.

@bjorn3 bjorn3 added the A-unwind Area: Unwinding label Aug 16, 2024
@lucasmerlin
Copy link
Author

Thank you for the explanation! My tests fail correctly now, haha.

Should this issue stay open until panic=unwind is supported?

@bjorn3
Copy link
Member

bjorn3 commented Aug 17, 2024

Let's keep it open in case someone else tries to search for this error message.

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

No branches or pull requests

2 participants