Skip to content

fix(ci): prevent macOS 26 streaming runner hangs - #3643

Merged
zackees merged 1 commit into
masterfrom
fix/3642-macos-streaming-race
Jul 15, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/3642-macos-streaming-race

Conversation

@zackees

@zackees zackees commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Closes #3642

Root cause

Ninja emits its Linking target progress line before ld64/lld has finished writing the dynamic library. The streaming path treated that line as completion and launched the shared runner against a partially linked artifact; macOS 26 can hang in dlopen before the runner watchdog starts. The same path also bypassed NO_PARALLEL.

Resolution

  • collect link targets during Ninja output, but launch nothing until the complete build succeeds and artifact mtimes are stable
  • honor NO_PARALLEL through the shared CPU-count helper
  • keep the cached-build fallback and make optimizer/submission waits cancellation-safe
  • add deterministic regressions for compile/run ordering, failed-link suppression, and single-worker mode
  • repair two current-master gate failures encountered during validation: KeyboardInterrupt cleanup handling and the AutoResearch filter expectation

Validation

  • RED: 3 focused regressions failed against the previous implementation
  • GREEN: 86 focused streaming/filter tests passed
  • bash lint
  • clean bash test --cpp --clean --no-fingerprint: 350/350 passed
  • Python suite with the documented Windows fbuild/QEMU skip: 501 passed, 40 skipped, 5 subtests passed
  • pre-push review: clean

Summary by CodeRabbit

  • New Features

    • Improved build-and-test reliability by completing compilation before launching tests.
    • Added support for parallel test execution while respecting no-parallel settings.
    • Strengthened validation to prevent missing, stale, or failed-build artifacts from running.
  • Bug Fixes

    • Keyboard interrupts during cleanup are now preserved and handled correctly.
  • Documentation

    • Updated build and test workflow documentation to reflect the revised execution order.

Wait for the complete Ninja build before launching dynamic-library runners, honor NO_PARALLEL, and add phase-boundary regressions. Also repair two current-master lint/test expectations encountered by the required gates.

Closes #3642
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The streaming runner now completes compilation and DLL stabilization before running tests, uses project-controlled worker counts, and adds coordination regressions. Watchdog cleanup handles interrupts explicitly, documentation reflects the new flow, and AutoResearch filter expectations are updated.

Changes

Streaming execution coordination

Layer / File(s) Summary
Compile-then-execute streaming flow
ci/meson/streaming.py, ci/meson/streaming_runner.py, ci/meson/README.md
Compilation collects artifacts and waits for DLL stabilization before creating the executor and submitting filtered tests; worker counts use the project CPU helper. Documentation and validation comments describe the deferred execution flow.
Streaming coordination regressions
ci/tests/test_streaming_runner_artifact_validation.py
Tests verify compile-before-run ordering, zero test execution after failed compilation, single-worker behavior under NO_PARALLEL, and the streaming result type.

Watchdog interrupt cleanup

Layer / File(s) Summary
Interrupt-aware watchdog cleanup
ci/autoresearch/phases.py
Client and recovery cleanup now route KeyboardInterrupt through the interrupt handler and re-raise it.

AutoResearch filter expectations

Layer / File(s) Summary
Updated filter parsing assertions
ci/tests/test_sketch_filter.py
The expected required board list is expanded, and the expected exclusion mapping is empty.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also changes unrelated autoresearch cleanup and sketch-filter expectations outside the macOS streaming-runner fix. Split the unrelated autoresearch and sketch-filter edits into a separate PR unless they are part of the linked issue scope.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing macOS 26 streaming runner hangs in CI.
Linked Issues check ✅ Passed The changes address #3642 by decoupling compile and run, honoring NO_PARALLEL, and adding regressions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3642-macos-streaming-race

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
ci/tests/test_sketch_filter.py (1)

738-750: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the newly added LPC boards through the compile-path test.

The parsing assertion now includes lpc845, lpc845brk, lpcxpresso845max, and lpcxpresso804, but test_autoresearch_supported_boards_compile still tests only the original five boards. Add the four LPC boards to that parametrization so filtering and board compatibility are verified end to end.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/tests/test_sketch_filter.py` around lines 738 - 750, Update the board
parametrization for test_autoresearch_supported_boards_compile to include
lpc845, lpc845brk, lpcxpresso845max, and lpcxpresso804 alongside the existing
boards, ensuring the newly parsed LPC boards are covered by the compile-path
test.
ci/tests/test_streaming_runner_artifact_validation.py (1)

123-184: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Ordering assertions are sound, but the simulated on_test_compiled callback is dead code.

stream_compile_only's real signature (ci/meson/streaming.py) no longer accepts an on_test_compiled kwarg — that callback path was removed as part of this PR. fake_compile_only's kwargs.get("on_test_compiled") therefore always resolves to None in both tests here, so the "pre-link callback fires early" simulation never actually runs. The tests still correctly validate the real invariant (execution deferred until stream_compile_only returns, and suppressed on failure) via compile_finished/early-return, so this doesn't weaken the regression — it's just vestigial from the prior callback-based design and slightly overstates what's being simulated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/tests/test_streaming_runner_artifact_validation.py` around lines 123 -
184, Remove the obsolete on_test_compiled callback simulation from
fake_compile_only in test_test_starts_after_compile_completes and
test_failed_compile_runs_no_tests. Keep the compile_finished tracking,
CompileOnlyResult returns, and existing assertions so the tests continue
validating deferred execution and suppression after failed compilation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/meson/streaming.py`:
- Around line 522-529: Bound the wait loop in stream_compile_only around
dll_touch_done so it has an overall deadline instead of waiting indefinitely.
Keep the short timed waits for Ctrl+C responsiveness, and fail fast with an
appropriate error when _touch_dlls_bg() does not signal completion before the
deadline.

---

Nitpick comments:
In `@ci/tests/test_sketch_filter.py`:
- Around line 738-750: Update the board parametrization for
test_autoresearch_supported_boards_compile to include lpc845, lpc845brk,
lpcxpresso845max, and lpcxpresso804 alongside the existing boards, ensuring the
newly parsed LPC boards are covered by the compile-path test.

In `@ci/tests/test_streaming_runner_artifact_validation.py`:
- Around line 123-184: Remove the obsolete on_test_compiled callback simulation
from fake_compile_only in test_test_starts_after_compile_completes and
test_failed_compile_runs_no_tests. Keep the compile_finished tracking,
CompileOnlyResult returns, and existing assertions so the tests continue
validating deferred execution and suppression after failed compilation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 707cf992-1165-4f7d-9332-226bd98d59b7

📥 Commits

Reviewing files that changed from the base of the PR and between 24b4cfc and 77b97b0.

📒 Files selected for processing (6)
  • ci/autoresearch/phases.py
  • ci/meson/README.md
  • ci/meson/streaming.py
  • ci/meson/streaming_runner.py
  • ci/tests/test_sketch_filter.py
  • ci/tests/test_streaming_runner_artifact_validation.py

Comment thread ci/meson/streaming.py
Comment on lines +522 to +529
# The build optimizer may still be touching DLL mtimes after Ninja exits.
# Wait before stabilization and before returning artifacts to the caller;
# loading a DLL concurrently with os.utime() fails intermittently on
# Windows and can race the macOS dynamic loader.
# Poll so Ctrl+C remains responsive if the optimizer thread stalls.
while not dll_touch_done.wait(timeout=0.2):
pass

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the file and locate relevant symbols
ast-grep outline ci/meson/streaming.py --view expanded

# Find the wait loop and related event/thread handling
rg -n "dll_touch_done|_touch_dlls_bg|compile_timeout|RunningProcess|stream_compile_only|touch_dll" ci/meson/streaming.py

# Read the surrounding section around the wait loop
sed -n '460,560p' ci/meson/streaming.py

# Read the thread function and any finally/set paths
sed -n '1,220p' ci/meson/streaming.py

Repository: FastLED/FastLED

Length of output: 14019


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the DLL touch thread and the end of producer_thread
sed -n '260,340p' ci/meson/streaming.py
sed -n '340,460p' ci/meson/streaming.py

# Inspect the exact wait-loop context with a bit more surrounding code
sed -n '510,540p' ci/meson/streaming.py

Repository: FastLED/FastLED

Length of output: 11739


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the build optimizer implementation and the DLL touch helper
fd -a "build_optimizer.py" ci
fd -a "mtime_stabilizer.py" ci
rg -n "def touch_dlls_if_lib_unchanged|touch_dlls_if_lib_unchanged|timeout|wait\\(|sleep\\(" ci/meson/build_optimizer.py ci/meson/mtime_stabilizer.py

# Read the helper implementation
sed -n '1,260p' ci/meson/build_optimizer.py
sed -n '1,220p' ci/meson/mtime_stabilizer.py

Repository: FastLED/FastLED

Length of output: 11813


Bound the DLL-touch wait
_touch_dlls_bg() always sets dll_touch_done on exit, so the risk here is a hung filesystem operation, not a missed finally. This loop still has no overall deadline, which can block stream_compile_only() forever; add a timeout and fail fast if the optimizer never finishes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/meson/streaming.py` around lines 522 - 529, Bound the wait loop in
stream_compile_only around dll_touch_done so it has an overall deadline instead
of waiting indefinitely. Keep the short timed waits for Ctrl+C responsiveness,
and fail fast with an appropriate error when _touch_dlls_bg() does not signal
completion before the deadline.

Source: Coding guidelines

@zackees
zackees merged commit c4e8d59 into master Jul 15, 2026
12 of 13 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 15, 2026
zackees added a commit that referenced this pull request Jul 15, 2026
* fix(ci): bound DLL touch optimizer wait

Fail the streaming build with a propagated diagnostic if DLL mtime optimization stalls. Add timeout coverage, exercise the newly supported LPC AutoResearch boards, and document the intentional pre-fix regression hook.

Follow-up to #3643.

* fix(ci): bound and diagnose Apple runner hangs

* fix(ci): work around Apple ASan global deadlock

* fix(ci): use Xcode sanitizer runtime on macOS

* fix(ci): use Xcode toolchain for Apple sanitizers

* fix(ci): provide macOS SDK to Xcode toolchain

* fix(ci): disable unsupported Apple leak detection
@zackees
zackees deleted the fix/3642-macos-streaming-race branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(ci): prevent macOS 26 ASan startup hangs

1 participant