Skip to content

parallel compiler: threads::spawnning loop not reproducible聽#150451

Description

@matthiaskrgr

View all comments

I tried this code:

use std::thread;

fn _main() {
    let _t1 = thread::spawn(|| {
        for _ in 0..100 {
            println!("test");
        }
    });
}

compiled with RUSTFLAGS="" rustc a.rs -Zthreads=3 --crate-type lib -Clink-dead-code=true -Copt-level=0 -Ccodegen-units=1 ; md5sum liba.rlib

I expected to see this happen: explanation
same checksums all the time

Instead, this happened: explanation
different checksums:

ddeb820dec9e3451d3353aa1041e4ef3  liba.rlib
0604d96b3340f2b6e3bed389738515c9  liba.rlib
0604d96b3340f2b6e3bed389738515c9  liba.rlib
ddeb820dec9e3451d3353aa1041e4ef3  liba.rlib
0604d96b3340f2b6e3bed389738515c9  liba.rlib
0604d96b3340f2b6e3bed389738515c9  liba.rlib
3c3905784182c1b6958da68edba17c5d  liba.rlib
ddeb820dec9e3451d3353aa1041e4ef3  liba.rlib

Meta

rustc --version --verbose:

rustc 1.94.0-nightly (1107bbac4 2025-12-26)
binary: rustc
commit-hash: 1107bbac4b303d49c3e67a2ec62710902bf4b341
commit-date: 2025-12-26
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

Metadata

Metadata

Assignees

Labels

A-parallel-compilerArea: parallel compilerA-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions