rust-lang / rust-lang/rust

parallel: --emit=mir not reproducible (alloc ids)

Open
#154,278 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-MIR A-parallel-compiler A-reproducibility C-bug needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

pub struct A<T> { pub v: T }
pub struct B<T> { pub v: T }

pub mod test {
    pub struct A<T> { pub v: T }

    impl<T> A<T> {
        pub fn foo(&self) -> isize {
            static a: isize = 5;
            return a
        }

        pub fn bar(&self) -> isize {
            static a: isize = 6;
            return a;
        }
    }
}



rustc inner_static.rs --emit=mir --crate-type lib -o out -Zthreads=60 ; md5sum out

I expected to see this happen: explanation
equal md5s

Instead, this happened: explanation
different md5s

ba0be6d56e74c5a05f5b5964a2a9ca3c
fcc907ca72b311ae42bd6fe7d3a0ad91
--- 1	2026-03-23 22:42:02.040187880 +0100
+++ 2	2026-03-23 22:41:53.408130384 +0100
@@ -7,13 +7,13 @@
     let mut _2: &isize;

     bb0: {
-        _2 = const {alloc2: &isize};
+        _2 = const {alloc1: &isize};
         _0 = copy (*_2);
         return;
     }
 }

-alloc2 (static: test::A::<T>::foo::a, size: 8, align: 8) {
+alloc1 (static: test::A::<T>::foo::a, size: 8, align: 8) {
     05 00 00 00 00 00 00 00                         │ ........
 }

@@ -32,13 +32,13 @@
     let mut _2: &isize;

     bb0: {
-        _2 = const {alloc1: &isize};
+        _2 = const {alloc2: &isize};
         _0 = copy (*_2);
         return;
     }
 }

-alloc1 (static: test::A::<T>::bar::a, size: 8, align: 8) {
+alloc2 (static: test::A::<T>::bar::a, size: 8, align: 8) {
     06 00 00 00 00 00 00 00                         │ ........
 }
Meta

rustc --version --verbose:

rustc 1.96.0-nightly (562dee482 2026-03-21)
binary: rustc
commit-hash: 562dee4820c458d823175268e41601d4c060588a
commit-date: 2026-03-21
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided rustc command, --emit=mir, and -Zthreads=60, then inspect how MIR allocation IDs are assigned during parallel compilation. Compare repeated outputs and the shown MIR diff. Done means identical output, including stable alloc IDs, across repeated runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.