Open
Description
I tried this code:
// Checks that mutable static items can have mutable slices and other references
pub static mut TEST: &'static mut [isize] = &mut [1];
pub static mut EMPTY: &'static mut [isize] = &mut [];
pub static mut INT: &'static mut isize = &mut 1;
// And the same for raw pointers.
pub static mut TEST_RAW: *mut [isize] = &mut [1isize] as *mut _;
pub static mut EMPTY_RAW: *mut [isize] = &mut [] as *mut _;
pub static mut INT_RAW: *mut isize = &mut 1isize as *mut _;
pub fn main() {
unsafe {
TEST[0] += 1;
assert_eq!(TEST[0], 2);
*INT_RAW += 1;
assert_eq!(*INT_RAW, 2);
}
}
I expected to see this happen: explanation
rustc static-mut-refs.rs -Zthreads=50 ; md5sum static-mut-refs
same md5sum throughout
Instead, this happened: explanation
different md5sums
Meta
rustc --version --verbose
:
rustc 1.88.0-nightly (cb31a009e 2025-04-27)
binary: rustc
commit-hash: cb31a009e3e735ab08613cec2d8a5a754e65596f
commit-date: 2025-04-27
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Hexyl diff:
Backtrace
--- /proc/self/fd/11 2025-04-28 23:42:10.077362393 +0200
+++ /proc/self/fd/12 2025-04-28 23:42:10.078362382 +0200
@@ -49,8 +49,8 @@
β000002f0β 78 38 36 2d 36 34 2e 73 β 6f 2e 32 00 04 00 00 00 βx86-64.sβo.2ββ’ββββ
β00000300β 10 00 00 00 01 00 00 00 β 47 4e 55 00 00 00 00 00 ββ’ββββ’ββββGNUββββββ
β00000310β 04 00 00 00 04 00 00 00 β 00 00 00 00 04 00 00 00 ββ’ββββ’βββββββββ’ββββ
-β00000320β 14 00 00 00 03 00 00 00 β 47 4e 55 00 bb 4a 26 97 ββ’ββββ’ββββGNUβΓJ&Γβ
-β00000330β d3 22 de 98 c0 42 ed af β 96 d7 c7 4c 12 06 7d 3c βΓ"ΓΓΓBΓΓβΓΓΓLβ’β’}<β
+β00000320β 14 00 00 00 03 00 00 00 β 47 4e 55 00 4d 35 9d a9 ββ’ββββ’ββββGNUβM5ΓΓβ
+β00000330β 5d 31 c4 8c 19 1b d9 29 β 05 79 1f 07 5c e4 f7 e9 β]1ΓΓβ’β’Γ)ββ’yβ’β’\ΓΓΓβ
β00000340β 00 00 00 00 00 00 00 00 β 00 00 00 00 00 00 00 00 βββββββββββββββββββ
β00000350β 00 00 00 00 00 00 00 00 β 01 00 00 00 12 00 00 00 βββββββββββ’ββββ’ββββ
β00000360β 00 00 00 00 00 00 00 00 β 00 00 00 00 00 00 00 00 βββββββββββββββββββ
@@ -1338,9 +1338,9 @@
β00005380β 08 00 00 00 00 00 00 00 β 10 1a 05 00 00 00 00 00 ββ’βββββββββ’β’β’ββββββ
β00005390β 30 7d 05 00 00 00 00 00 β 08 00 00 00 00 00 00 00 β0}β’βββββββ’ββββββββ
β000053a0β 30 7d 05 00 00 00 00 00 β 38 7d 05 00 00 00 00 00 β0}β’ββββββ8}β’ββββββ
-β000053b0β 08 00 00 00 00 00 00 00 β 50 7d 05 00 00 00 00 00 ββ’ββββββββP}β’ββββββ
+β000053b0β 08 00 00 00 00 00 00 00 β 58 7d 05 00 00 00 00 00 ββ’ββββββββX}β’ββββββ
β000053c0β 40 7d 05 00 00 00 00 00 β 08 00 00 00 00 00 00 00 β@}β’βββββββ’ββββββββ
-β000053d0β 58 7d 05 00 00 00 00 00 β 60 7d 05 00 00 00 00 00 βX}β’ββββββ`}β’ββββββ
+β000053d0β 50 7d 05 00 00 00 00 00 β 60 7d 05 00 00 00 00 00 βP}β’ββββββ`}β’ββββββ
β000053e0β 08 00 00 00 00 00 00 00 β 30 6d 03 00 00 00 00 00 ββ’ββββββββ0mβ’ββββββ
β000053f0β 70 7d 05 00 00 00 00 00 β 08 00 00 00 00 00 00 00 βp}β’βββββββ’ββββββββ
β00005400β 30 7d 05 00 00 00 00 00 β 80 7d 05 00 00 00 00 00 β0}β’ββββββΓ}β’ββββββ
@@ -226171,8 +226171,8 @@
β00374c10β 40 7d 05 00 00 00 00 00 β 10 00 00 00 00 00 00 00 β@}β’βββββββ’ββββββββ
β00374c20β 2c 03 00 00 01 00 1d 00 β 38 7d 05 00 00 00 00 00 β,β’βββ’ββ’ββ8}β’ββββββ
β00374c30β 08 00 00 00 00 00 00 00 β 5d 03 00 00 01 00 1d 00 ββ’ββββββββ]β’βββ’ββ’ββ
-β00374c40β 50 7d 05 00 00 00 00 00 β 08 00 00 00 00 00 00 00 βP}β’βββββββ’ββββββββ
-β00374c50β ad 03 00 00 01 00 1d 00 β 58 7d 05 00 00 00 00 00 βΓβ’βββ’ββ’ββX}β’ββββββ
+β00374c40β 58 7d 05 00 00 00 00 00 β 08 00 00 00 00 00 00 00 βX}β’βββββββ’ββββββββ
+β00374c50β ad 03 00 00 01 00 1d 00 β 50 7d 05 00 00 00 00 00 βΓβ’βββ’ββ’ββP}β’ββββββ
β00374c60β 08 00 00 00 00 00 00 00 β 62 8a 00 00 02 02 0f 00 ββ’ββββββββbΓβββ’β’β’ββ
β00374c70β a0 4e 01 00 00 00 00 00 β 23 00 00 00 00 00 00 00 βΓNβ’ββββββ#ββββββββ
β00374c80β 52 8d 00 00 01 02 1d 00 β 60 7d 05 00 00 00 00 00 βRΓβββ’β’β’ββ`}β’ββββββ