File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Regression test for https://github.com/rust-lang/rust/issues/150898
2+ //
3+ // This test fails on Apple platforms with versions containing an allocator
4+ // bug. If this fails with SIGABRT, you may need to upgrade your system to
5+ // avoid other unexpected behavior.
6+ //
7+ // Note that the failure is non-deterministic so this test may pass even in
8+ // conditions where the bug is present. That being said, on the author's
9+ // machine this has a 100% rate of hitting the crash on at least a couple
10+ // threads.
11+ //
12+ // The bug was resolved by macOS 26.4.
13+
14+ //@ run-pass
15+ //@ only-aarch64-apple-darwin
16+ //@ compile-flags: -C opt-level=1 -C codegen-units=1
17+
18+ use std:: thread;
19+
20+ fn main ( ) {
21+ // Running with multiple threads substantially increases the change of
22+ // hitting the bug.
23+ thread:: scope ( |s| {
24+ for _ in 0 ..10 {
25+ s. spawn ( run) ;
26+ }
27+ } ) ;
28+ }
29+
30+ fn run ( ) {
31+ // This doesn't always fail, so rerun a few times
32+ for _ in 0 ..100 {
33+ unsafe {
34+ core:: arch:: asm!(
35+ "
36+ // Alloc 18 bytes
37+ mov x0, #18
38+ bl _malloc
39+ // Save the pointer to x21
40+ mov x21, x0
41+ // Alloc 18 bytes again
42+ mov x0, #18
43+ bl _malloc
44+ // Store the contents of `x13` to the second allocation. `x13` is the
45+ // magic register to cause the crash, other registers work well.
46+ str x13, [x0]
47+ // Free the pointers
48+ bl _free
49+ mov x0, x21
50+ bl _free
51+ " ,
52+ out( "x0" ) _,
53+ out( "x13" ) _,
54+ out( "x21" ) _,
55+ clobber_abi( "C" ) ,
56+ )
57+ }
58+ }
59+ }
You can’t perform that action at this time.
0 commit comments