Skip to content

parallel rustc: static mut refs not reproducible #140413

Open
@matthiaskrgr

Description

@matthiaskrgr

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×⋄⋄•••⋄┊`}•⋄⋄⋄⋄⋄│

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parallel-compilerArea: parallel compilerA-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions