Skip to content

fix: prevent concurrent XIP extraction race (with regression test)#797

Open
iXerol wants to merge 2 commits intoXcodesOrg:mainfrom
iXerol:codex/test-concurrent-xip-extraction-race
Open

fix: prevent concurrent XIP extraction race (with regression test)#797
iXerol wants to merge 2 commits intoXcodesOrg:mainfrom
iXerol:codex/test-concurrent-xip-extraction-race

Conversation

@iXerol
Copy link

@iXerol iXerol commented Mar 7, 2026

Summary

Fix a race condition when installing multiple Xcode versions concurrently, and add a regression test that verifies the fix.

Root cause

Before this change, multiple .xip extractions could share the same parent extraction location (Xcode.app / Xcode-beta.app). Under concurrent installs, one extracted app could be moved to another version's destination, causing rename/move conflicts and failed installs.

Changes

  • Use a version-specific extraction directory during unarchive:
    • Xcode-<version>-extract/
  • Update shell unarchive APIs to accept an explicit extraction working directory.
  • Keep extraction directory cleanup in success/cancel paths.
  • Add regression test:
    • test_UnarchiveAndMoveXIP_ConcurrentInstalls_DoNotShareExtractionDirectory
    • Simulates concurrent installs and asserts no directory collision and successful moves for both versions.

Validation

  • Targeted test passed:
    • xcodebuild test -project Xcodes.xcodeproj -scheme Xcodes -destination 'platform=macOS,arch=x86_64' -only-testing:XcodesTests/AppStateTests/test_UnarchiveAndMoveXIP_ConcurrentInstalls_DoNotShareExtractionDirectory

Historical reproduction (pre-fix)

I also validated equivalent behavior against pre-fix commit 1a0d335 in a temporary worktree:

  • Concurrent installs sharing one extraction parent can collide.
  • Observed expected pre-fix failure pattern: one succeeds, one fails.

This confirms the race was real and that this PR both fixes it and guards against regression.

iXerol and others added 2 commits March 7, 2026 17:40
…oncurrently

Each XIP is now extracted into a version-specific directory (e.g. Xcode-16.0-extract/)
instead of sharing the same parent directory, eliminating the race where one version's
extracted Xcode.app could be moved to another version's destination path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@iXerol iXerol changed the title test: add regression test for concurrent XIP extraction race fix: prevent concurrent XIP extraction race (with regression test) Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant