← Back to Pull requests

Fix CFRunLoop timeouts breaking under coarse-resolution CLOCK_MONOTONIC #5485

Closed
unknown closed this pull request without merging on Jul 06, 2026 15:13 UTC
View on GitHub
unknown unknown commented on May 27, 2026 21:43 UTC
Author

This fixes an issue affecting Linux/BSD/WASI where the TSR rate in CFDate.c may be incorrect. This rate is derived from the resolution of CLOCK_MONOTONIC, but on some systems this clock has coarser resolution. It's used by a shim of mach_absolute_time() and multiplied by a constant factor that assumes a more granular resolution, so on systems with coarser resolution the times will be incorrect.

Fixes rdar://139710145

Motivation:

The practical scenario where this bug has been observed most often is when running XCTests in Linux via Docker on macOS. Linux Docker uses a clock with a coarser-resolution CLOCK_MONOTONIC than "bare metal" Linux. This leads to timeout calculation errors in Foundation's RunLoop, which XCTest relies on heavily for many features including handling async test methods. The end result is that trivial XCTest suites involving async methods can hang in this environment once every 1-4 attempts.

Modifications:

Stop using clock_getres(CLOCK_MONOTONIC, ...) to determine TSR rate on Linux (and the other affected platforms in this #if branch) and instead hardcode the same rate that is used in the mach_absolute_time() shim above, NSEC_PER_SEC.

Result:

The XCTest hang no longer reproduces after many thousands of attempts in a loop, after reliably reproducing after 1-4 attempts previously.

Testing:

Verified via testing above.

Diff: 216 lines (+162 / -54) across 2 files Reviewer: weissi Review duration: 57210m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 216 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.322
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5485"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.6% (MEDIUM) · Higher = larger blast radius
36.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.5% · Safe to merge
14.5%