Skip to content

Fix data race in jl_new_module__ #58880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,10 @@ static jl_module_t *jl_new_module__(jl_sym_t *name, jl_module_t *parent)
m->parent = parent ? parent : m;
m->istopmod = 0;
m->uuid = uuid_zero;
static unsigned int mcounter; // simple counter backup, in case hrtime is not incrementing
static _Atomic(unsigned int) mcounter; // simple counter backup, in case hrtime is not incrementing
unsigned int count = jl_atomic_fetch_add_relaxed(&mcounter, 1);
// TODO: this is used for ir decompression and is liable to hash collisions so use more of the bits
m->build_id.lo = bitmix(jl_hrtime() + (++mcounter), jl_rand());
m->build_id.lo = bitmix(jl_hrtime() + count, jl_rand());
if (!m->build_id.lo)
m->build_id.lo++; // build id 0 is invalid
m->build_id.hi = ~(uint64_t)0;
Expand Down