fix TOCTOU race when reading xcbuilddata bundle #3295
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 457 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.367
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3295"
general
weight: 0.35
brentleyjones
Summary
Fixes a race condition in
calculate_output_groups.pythat causes intermittent build failures when Xcode deletes.xcbuilddatabundles concurrently with the pre-build script.Problem
The
wait_for_build_request()function usesglob.iglob()(a lazy generator) withos.path.getctime()as the key formax(). Because the generator yields paths lazily, there's a window between when a path is yielded and whengetctime()is called during which Xcode's build system can delete or replace the.xcbuilddatabundle. This results in aFileNotFoundErrorthat bypasses the_wait_for_value()retry loop and fails the build.This particularly affects CI environments where DerivedData is reused across builds—stale
.xcbuilddatabundles from previous runs are present when a new build starts, and Xcode begins replacing them concurrently with the pre-build script.Example failure:
Solution
Wrap both
getctime()call sites in try/except blocks that catch:ValueError(empty glob, no.xcbuilddatafiles yet)FileNotFoundError/OSError(TOCTOU race—file deleted between glob and getctime)When these exceptions occur, return
Noneto allow_wait_for_value()to retry properly instead of crashing.Testing