Skip to content

Rust 1.65 - failed assert_eq! causes crash with SIGSEGV #104441

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

Closed
wg opened this issue Nov 15, 2022 · 2 comments
Closed

Rust 1.65 - failed assert_eq! causes crash with SIGSEGV #104441

wg opened this issue Nov 15, 2022 · 2 comments

Comments

@wg
Copy link
Contributor

wg commented Nov 15, 2022

I tried this code:

assert_eq!("foo", "bar");

I expected the program to panic with an assertion failed message and exit normally:

% cargo +1.64.0 run
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/test-segv`
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"foo"`,
 right: `"bar"`', src/main.rs:7:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Instead, the program crashes with a segfault:

% cargo +1.65.0 run
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/test-segv`
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"foo"`,
 right: `"bar"`', src/main.rs:7:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
zsh: segmentation fault  cargo +1.65.0 run

This is particularly a problem with tests since the test harness doesn't print the failed assert:

running 1 test
error: test failed, to rerun pass `--bin test-segv`

Caused by:
  process didn't exit successfully: `.../target/debug/deps/test_segv-1bd8c9f311fdbb76` (signal: 11, SIGSEGV: invalid memory reference)

This crash occurs on aarch64-apple-darwin, it does not occur on aarch64-unknown-linux-gnu

Meta

% cargo +1.65.0 rustc -- --version --verbose
   Compiling test-segv v0.0.1 (/Users/will/src/rust-play/test-segv)
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: aarch64-apple-darwin
release: 1.65.0
LLVM version: 15.0.0
Backtrace Backtrace from lldb:

* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001ca48f4f4 libunwind.dylib`libunwind::CFI_Parser<libunwind::LocalAddressSpace>::decodeFDE(libunwind::LocalAddressSpace&, unsigned long, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::FDE_Info*, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::CIE_Info*) + 48
    frame #1: 0x00000001ca49159c libunwind.dylib`libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step() + 204
    frame #2: 0x00000001ca493314 libunwind.dylib`_Unwind_RaiseException + 468
    frame #3: 0x000000010001a3e0 test-segv`rust_panic at panicking.rs:746:9 [opt]

@wg wg added the C-bug Category: This is a bug. label Nov 15, 2022
@wg
Copy link
Contributor Author

wg commented Nov 15, 2022

Oops sorry this is a duplicate of #104388 caused by using -C link-arg=--ld-path=/opt/homebrew/opt/llvm/bin/ld64.lld from LLVM 14.0.6_1. The crash does not occur without that link arg flag, and also doesn't occur after upgrading to LLVM 15.0.4.

@skyzh
Copy link
Contributor

skyzh commented Nov 15, 2022

I believe this is caused by using ld from LLVM 14 to link artifacts produced by LLVM 15. Seems to dup w/ #104388 but it seems that you have a smaller reproducible code. Could you please share your MCVE?

@saethlin saethlin added S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. and removed C-bug Category: This is a bug. needs-triage-legacy S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. labels Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants