fix: serialize mkdir shell fork on the run_command lock#1298
Open
krystophny wants to merge 1 commit into
Open
Conversation
build_target created the output directory inside an unnamed `!$omp critical`. mkdir shells out twice (is_dir runs `test -d`, then `mkdir -p`), and both fork. The unnamed critical is a different lock than `critical(run_command)` that guards every other shell fork (the compile/link/archive fallbacks), so a mkdir fork on one thread could run concurrently with a run_command fork on another - the exact concurrent-fork hazard the run_command lock exists to prevent. Put the directory creation under `critical(run_command)` so all shell forks share one lock.
This was referenced Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
build_targetfrom an unnamed!$omp criticalto the named
critical(run_command)lock that guards all other shell forksis_dirrunstest -d, thenmkdir -p), both ofwhich fork; the unnamed critical was a different lock than
run_command, so amkdir fork on one thread could run concurrently with a compile/link/archive
shell fallback on another — the exact concurrent-fork hazard the
run_commandlock exists to preventMerge order
Independent — no ordering constraint. Logically related to the argv spawn chain
but does not depend on it.
Note: textual overlap with #1289 (interface-aware rebuild) — both edit the
!$omp criticalblock inbuild_target. Whichever merges second rebases.Independent PRs (any order):
Stacked chain (merge in order):
Fork-safety fix:
After the above:
Refs: #962
Verification