Skip to content

[RAI-47876] Hard-code semaphore name to avoid thread-unsafe getenv calls#276

Merged
kpamnany merged 2 commits intov1.10.2+RAIfrom
ib-RAI-47876-env-not-threadsafe
Mar 4, 2026
Merged

[RAI-47876] Hard-code semaphore name to avoid thread-unsafe getenv calls#276
kpamnany merged 2 commits intov1.10.2+RAIfrom
ib-RAI-47876-env-not-threadsafe

Conversation

@bunjj
Copy link

@bunjj bunjj commented Mar 3, 2026

Problem

Parallel precompilation semaphore coordination was using getenv("JL_AOT_PRECOMPILE_SEMAPHORE") to get the semaphore name. This caused thread-unsafe races with setenv/unsetenv calls in the parent Julia process, leading to segfaults in tests.

Related: JuliaLang#34726

Solution

Hard-code the semaphore name to /jl_aot_par_precomp_semaphore instead of reading from ENV:

  • Always try sem_open("/jl_aot_par_precomp_semaphore", 0) (without O_CREAT)
  • If semaphore exists: use it for coordination (compcache path)
  • If semaphore doesn't exist: skip coordination (normal compilation path)

Changes

  • src/aotcompile.cpp: Removed getenv call, hard-coded semaphore name, restructured logic

Dependencies

Paired with RAICode PR: https://github.com/RelationalAI/raicode/pull/27411

@bunjj bunjj requested a review from kpamnany March 4, 2026 09:49
@kpamnany kpamnany merged commit 6163028 into v1.10.2+RAI Mar 4, 2026
1 check passed
@kpamnany kpamnany deleted the ib-RAI-47876-env-not-threadsafe branch March 4, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants