Skip to content

cargo test fails with fatal runtime error on stable-aarch64-apple-darwin #105988

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

Open
segeljakt opened this issue Dec 21, 2022 · 4 comments
Open
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-macos Operating system: macOS S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@segeljakt
Copy link

segeljakt commented Dec 21, 2022

Code

#[test]
fn test() {
    assert!(false);
}

Meta

rustc --version --verbose:

rustc 1.66.0 (69f9c33d7 2022-12-12)
binary: rustc
commit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943
commit-date: 2022-12-12
host: aarch64-apple-darwin
release: 1.66.0
LLVM version: 15.0.2

Error output

helloworld ❯ RUST_BACKTRACE=1 cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests src/main.rs (target/debug/deps/helloworld-ed0dadb8f7ac71f4)

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

Caused by:
  process didn't exit successfully: `/Users/klasseg/Workspace/rust/helloworld/target/debug/deps/helloworld-ed0dadb8f7ac71f4` (signal: 6, SIGABRT: process abort signal)

No backtrace is printed.

The error is solved temporarily if I clean and rerun using:

cargo clean && env -i PATH="$HOME/.cargo/bin:/usr/bin:/bin" cargo test
@segeljakt segeljakt added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 21, 2022
@skyzh
Copy link
Contributor

skyzh commented Dec 23, 2022

Is it related to #104388?

To verify, use rust-lldb to run your program, see if the abort happens in libunwind.

To fix, simply brew install llvm@15 and use llvm-15's lld as the linker.

@JohnTitor JohnTitor added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-macos Operating system: macOS S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 14, 2023
@Qi-Hu
Copy link

Qi-Hu commented May 30, 2023

Does this error only occur on aarch64-apple-darwin? I tried it on x86_64-unknown-linux-gnu and didn't see the error.

Code

cat tests/test.rs:

#[test]
fn test() {
    assert!(false);
}

Meta

rustc -vV:

rustc 1.72.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.72.0-dev
LLVM version: 16.0.4

Output

RUST_BACKTRACE=1 cargo test:

   Compiling helloworld v0.1.0 (/home/q00815166/helloworld)
    Finished test [unoptimized + debuginfo] target(s) in 0.24s
     Running unittests src/main.rs (target/debug/deps/helloworld-df59c9ac901802cb)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/test.rs (target/debug/deps/test-15c53ff575d885af)

running 1 test
test test ... FAILED

failures:

---- test stdout ----
thread 'test' panicked at 'assertion failed: false', tests/test.rs:3:5
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: test::test
             at ./tests/test.rs:3:5
   4: test::test::{{closure}}
             at ./tests/test.rs:2:11
   5: core::ops::function::FnOnce::call_once
             at /home/q00815166/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

error: test failed, to rerun pass `--test test`

The test failed as expected.

@skyzh
Copy link
Contributor

skyzh commented May 30, 2023

This only happens on macOS and the specific version of rustc.

@memark
Copy link

memark commented Aug 3, 2023

I can reproduce this on 1.71.0 as well as on nightly:

❯ rustc -vV
rustc 1.71.0 (8ede3aae2 2023-07-12)
binary: rustc
commit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225
commit-date: 2023-07-12
host: aarch64-apple-darwin
release: 1.71.0
LLVM version: 16.0.5

❯ rustc +nightly -vV
rustc 1.73.0-nightly (d12c6e947 2023-08-01)
binary: rustc
commit-hash: d12c6e947ceacf3b22c154caf9532b390d8dc88a
commit-date: 2023-08-01
host: aarch64-apple-darwin
release: 1.73.0-nightly
LLVM version: 16.0.5

Other info:

  • Mac M1 Max
  • MacOS Sonoma public beta 2
❯ sw_vers
ProductName:		macOS
ProductVersion:		14.0
BuildVersion:		23A5301h

❯ uname -a
Darwin MEMac.local 23.0.0 Darwin Kernel Version 23.0.0: Tue Jul 18 20:35:35 PDT 2023; root:xnu-10002.0.199.505.1~3/RELEASE_ARM64_T6000 arm64 arm Darwin

@skyzh, that fix works, thank you!

Can I help out with rust-lldb as you hinted? I'm not sure how to use it to run my test.


For anyone else coming to this thread:

  • The llvm fix can be applied to all your rust projects by
    • running brew install llvm@15
    • adding build.rustflags = [ "-Clink-arg=-fuse-ld=/opt/homebrew/opt/llvm@15/bin/ld64.lld" ] to ~/.cargo/config.toml
  • the cargo clean && env -i fix suggested above doesn't seem to work (anymore?)
  • using cargo-nextest still gives the error, but doesn't crash the test runner and shows the expected info about which tests failed and so on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-macos Operating system: macOS S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants