Fix race condition in dependency archive creation#76
Merged
Conversation
archiveDependencyTargets deleted libDep.a before recreating it with ar. When two CLI tests ran concurrently (snapshot + variants suites), the delete-then-recreate window allowed a concurrent compileCombined call to see the archive as missing, causing "ld: library 'LocalDep' not found". Fix: write to a temp file and atomically rename via replaceItemAt, so the archive is never absent from the linker's perspective. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review feedback: - UUID-based temp filename prevents collisions between concurrent callers - replaceItemAt errors are propagated, with moveItem fallback for first build - Removes stale-temp cleanup that could delete another caller's file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Fixes intermittent CI failure:
ld: library 'LocalDep' not foundduring CLI integration tests.Root Cause
archiveDependencyTargetsdeletedlibDep.abefore recreating it withar rcs. TheCLI snapshot commandandCLI variants commandtest suites run in parallel — when a snapshot test calleddetectAndBuild(which re-archives dependencies) while the variants test was between its first and secondcompileCombinedcalls, the linker saw the archive as missing during the delete-to-recreate window.The race was exposed by #74's progress reporting, which adds small
awaitpauses between operations, widening the timing window.Fix
Write to a temp file (
libDep.a.tmp) and atomically rename viaFileManager.replaceItemAt, so the archive is never absent from the linker's perspective.Test plan
swift buildsucceedspreviewsmcp variants --variant light --variant darkproduces both images🤖 Generated with Claude Code