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