Regression `-Zsanitizer=thread` crashes any program on arm64 in nightly.

Đang mở
#166,163 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
compilers

Hướng nghiên cứu

Start by checking the compiler-builtins update and the AArch64 outlined atomic helpers mentioned in the issue, then reproduce with the supplied -Zsanitizer=thread -Zbuild-std command on aarch64. The backtrace points to __aarch64_swp1_acq during ThreadSanitizer initialization; verify whether that helper is instrumented and whether disabling its instrumentation addresses the crash. Done means the minimal program runs without a segmentation fault on nightly.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

A-sanitizers C-bug I-prioritize needs-triage O-AArch64 regression-from-stable-to-nightly T-compiler T-libs

-Zsanitizer=thread crashes any program on arm64 in nightly.

I found this while using Claude Code with Opus 5.5/Sonnet 5.5/Fable 5.2, output from the LLM will be clearly marked, other output is tested and verified by myself, every text here is written by myself if not otherwise marked :-)

Code

I tried this code with latest nightly:

fn main() {
    println!("Hello, world!");
}

I expected to see this output when running the program:

Hello, world!

Instead, this happened:

Segmentation fault         (core dumped) RUSTFLAGS=-Zsanitizer=thread cargo +nightly run -Zbuild-std --target aarch64-unknown-linux-gnu
Version it worked on

stable 1.100.0 (0ef1bc386 2026-11-09)

Claude Codes bisection for this, rewritten by myself

  • stable 1.100.0 (0ef1bc386 2026-11-09) -> ok
  • nightly-2026-09-01 (0dfb098f3) -> ok
  • nightly-2026-10-13 (e9bbadf68) -> ok
  • nightly-2026-10-15 (7df81381d) -> ok (last good)
  • nightly-2026-10-16 (4ebd25825) -> Error (first bad)
  • nightly-2026-10-28 (41089d07a) -> Error
  • nightly-2026-11-17 (59cbdee2e) -> Error

It most recently worked on (by bisection by Claude Code): stable 1.100.0 (0ef1bc386 2026-11-09) and nightly-2026-10-15 (7df81381d)

Version with regression (by bisection by Claude Code):

nightly-2026-10-16 (4ebd25825), nightly-2026-10-28 (41089d07a), nightly-2026-11-17 (59cbdee2e)
checked myself: 1.102.0-nightly (59cbdee2e 2026-11-17)

rustc --version --verbose:

rustup run nightly rustc --version --verbose
rustc 1.102.0-nightly (59cbdee2e 2026-11-17)
binary: rustc
commit-hash: 59cbdee2e7b3ee50e44b460561c43c9e3023d9f0
commit-date: 2026-11-17
host: aarch64-unknown-linux-gnu
release: 1.102.0-nightly
LLVM version: 23.1.5

Setting vm.mmap_rnd_bits to either 28 or 32 did not change any output.

The compiler did not crash, the program produced did crash:

Backtrace of running the programm
gdb -batch -ex run -ex bt target/aarch64-unknown-linux-gnu/debug/tsan-repo
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file [...]./target/aarch64-unknown-linux-gnu/debug/tsan-repo.
Use `info auto-load python-scripts [REGEXP]' to list them.

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.ubuntu.com>
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000aaaaaab314a8 in __tsan::TraceSwitchPart(__tsan::ThreadState*) ()
#0  0x0000aaaaaab314a8 in __tsan::TraceSwitchPart(__tsan::ThreadState*) ()
#1  0x0000aaaaaab3363c in __tsan::TraceRestartFuncEntry(__tsan::ThreadState*, unsigned long) ()
#2  0x0000aaaaaad18c78 in __aarch64_swp1_acq () at src/macros.rs:435
#3  0x0000aaaaaab51e78 in __sanitizer::MemoryMappingLayout::MemoryMappingLayout(bool) ()
#4  0x0000aaaaaab4693c in __tsan::CheckAndProtect(bool, bool, bool) ()
#5  0x0000aaaaaab45ff8 in __tsan::ReExecIfNeeded(bool) ()
#6  0x0000aaaaaab3053c in __tsan::Initialize(__tsan::ThreadState*) ()
#7  0x0000fffff7fc2e9c in _dl_init (main_map=0xfffff7fff340, argc=1, argv=0xffffffffe6c8, env=0xffffffffe6d8) at ./elf/dl-init.c:106
#8  0x0000fffff7fda648 in _start () at ../sysdeps/aarch64/dl-start.S:81

Claude Codes idea how it works currently:

Linking libgcc whole-archive makes it work:

Verified by me on that arm64:

RUSTFLAGS="-Zsanitizer=thread -Clink-arg=-Wl,--whole-archive -Clink-arg=$(cc -print-libgcc-file-name) -Clink-arg=-Wl,--no-whole-archive"  cargo +nightly run -Zbuild-std --target aarch64-unknown-linux-gnu

outputs:

Hello, world!
LLM analysis (unverified by me beyond everything above)

The following is LLM-generated analysis, quoted as such.

The only change in the range touching the affected code is #164333 (compiler-builtins subtree update), which brings in rust-lang/compiler-builtins#1321 ("Rewrite AArch64 outlined atomic functions with asm"). Before it, the __aarch64_{cas,swp,ldadd,…}* helpers were #[unsafe(naked)] functions, so sanitizer instrumentation never touched them. Now they are ordinary functions containing asm! plus a Rust load of HAVE_LSE_ATOMICS. With -Zbuild-std, compiler_builtins is compiled with -Zsanitizer=thread, so the helpers get __tsan_func_entry/__tsan_func_exit:

$ objdump -d --no-show-raw-insn target/aarch64-unknown-linux-gnu/debug/tsan-repro | grep -A12 '<__aarch64_swp1_acq>:'
<__aarch64_swp1_acq>:
  ...
  bl  <__tsan_func_entry>
  bl  <_RNvNtCs..._17compiler_builtins23aarch64_outline_atomics18___aarch64_swp1_acq>
  bl  <__tsan_func_exit>

The TSan runtime calls these helpers from __tsan::Initialize before its per-thread state exists, so the instrumented helper faults. rust-lang/compiler-builtins#1354 makes these the only implementation. A fix would be to keep the helpers uninstrumented again (naked, or #[sanitize(thread = "off")]).

Claude found related issues, didn't grasp those in their entirety:

Possibly related, but different: #151486, #161855.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Ngôn ngữ chính
Rust
Star
122k
Fork
16.7k
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
515

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-lang/rust

Tất cả issue của rust-lang/rust

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.