Regression `-Zsanitizer=thread` crashes any program on arm64 in nightly.
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
-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 containingasm!plus a Rust load ofHAVE_LSE_ATOMICS. With-Zbuild-std,compiler_builtinsis 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::Initializebefore 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
- 主要语言
- Rust
- 星标
- 122k
- 派生
- 16.7k
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 515
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-lang/rust 的其他 Issue
-
Remove unnecessary parentheses when suggesting to remove '&' from a pattern可能已有人在做 @BartSimpson001 于 1 天前认领。 未关闭A-diagnostics D-invalid-suggestion T-compiler
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
Windows `File::set_permissions` silently does nothing when clearing `readonly` leaves `FileAttributes == 0`可能已有人在做 @ChrisDenton 于 11 天前认领。 未关闭A-filesystem C-bug O-windows T-libs
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
难度 1/5 1 小时以内 新手友好度 72/100
rust-lang/rust#165504 · 1 条评论 ·
维护者通常 1 天内回复
-
relnotes relnotes-tracking-issue T-libs
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
bytecodealliance/wrpc#1785 ·
维护者通常 1 天内回复
-
2 advisory ignore entries no longer match anything (`quick-xml` already patched in `Cargo.lock`)未关闭
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
longbridge/nsh#2758 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
antithesishq/bombadil#473 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
libracoder/kiri#669 ·
维护者通常 1 天内回复