Repository navigation
fix(test): deadman watchdog + steal wedged build locks (#2430) - #2432
Conversation
) Fixes #2430. `bash test --cpp` could leave a hung Python process holding the libfastled_build SQLite lock past the 600s watchdog timeout, blocking every subsequent test invocation for 120s before timing out. Changes: 1. **Deadman watchdog** in test.py — adds a second-tier daemon that fires `_TIMEOUT_EVERYTHING + 60s` and unconditionally calls `os._exit(3)`. The primary watchdog can wedge in `dump_thread_stacks()` or psutil queries; the deadman bypasses all diagnostics so the process always dies on time. 2. **Lock cleanup before force-exit** — both the primary watchdog and the deadman now release any libfastled_build locks held by this PID before exiting, so subsequent runs are not blocked even if the diagnostics path stalls. 3. **Steal alive-but-wedged locks** in build_lock.py — `_check_stale_lock` now also breaks locks whose holder PID is alive but has held past `FASTLED_LOCK_MAX_HOLD_S` (default 3600s — well above the longest legitimate hold, including 2700s sequential debug-sanitizer builds). This is the safety net for the case where a process is wedged but neither watchdog tier fired. 4. **Kill hint in lock-timeout error** — the `Failed to acquire ...` error now includes a platform-aware `taskkill /F /PID N` (Windows) or `kill -9 N` (Unix) suggestion plus a pointer to `lock_admin --clean-stale`. 5. **Line-buffer stdout/stderr when piped** — defends against the silent `bash test --cpp 2>&1 | tail -15` zero-byte-output symptom by forcing line buffering when stdout is not a TTY, so each `\n`-terminated line surfaces immediately to the consuming pipe. Tests: new `ci/tests/test_build_lock_wedged_steal.py` covers the wedged-but-alive steal path (positive + negative case). All 32 existing lock tests still pass; `bash lint` clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR hardens the build-lock system against hung processes and improves test-runner observability. It introduces configurable wedged-lock detection (stealing locks held alive but past a max-hold threshold), a deadman-timer layer in the watchdog, explicit lock release before watchdog timeout, better piped-output visibility, and tests verifying the wedged-lock stealing behavior. ChangesBuild Lock Wedged-Hold Stealing & Watchdog Hardening
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
…3a of #2428) (#2433) Adds a non-template polymorphic anchor `fl::IChannel` so ChannelEvents callbacks keep working after `Channel<Bus, Chipset>` becomes a template in Phase 3b. Phase 3a is purely an API surface refactor -- no behavior changes: - New: src/fl/channels/ichannel.h. Minimal ABC with virtual `id()` and `name()`, noexcept special members, non-copyable/movable. Holds the public surface that any callback might reasonably want. - Channel now derives from CPixelLEDController<RGB> AND IChannel; existing `id()` / `name()` accessors marked `override`. - ChannelEvents callbacks change from `function_list<void(const Channel&, ...)>` to `function_list<void(const IChannel&, ...)>`. Callsites that fire events pass `*this` which upcasts implicitly via the new inheritance. - Test/doc lambdas migrated: tests/fastled_core.cpp EventTracker stores `const IChannel*`; lambdas in fastled_core.cpp, fl/channels/driver.cpp, fl/chipsets/ucs7604.cpp updated. README and FastLED.h docstrings refreshed. Also fixes pre-existing KBI checker failures in test.py (lines 186/193/211) flagged by lint -- the test-lock fix from #2432 introduced try-except blocks catching Exception without KeyboardInterrupt re-raise. Added the standard `except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki); raise` clause before each `except Exception`. Verification: - bash lint clean. - bash test --cpp passes (286/286). - ChannelEvents tests verified: pointer-identity comparisons `tracker.mLastChannel == channel.get()` still work because Channel inherits from IChannel (implicit upcast). Stacked on top of Phase 2 (#2431). When Phase 3b lands, Channel<B, Chipset> will simply derive from IChannel the same way -- no further event-system changes needed. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…3a of #2428) Adds a non-template polymorphic anchor `fl::IChannel` so ChannelEvents callbacks keep working after `Channel<Bus, Chipset>` becomes a template in Phase 3b. Pure API surface refactor -- no behavior changes. - New: src/fl/channels/ichannel.h. Minimal ABC with virtual `id()` and `name()`, noexcept special members, non-copyable/movable. Holds the public surface that any callback might reasonably want. - Channel now derives from CPixelLEDController<RGB> AND IChannel; existing `id()` / `name()` accessors marked `override`. - ChannelEvents callbacks change from `function_list<void(const Channel&, ...)>` to `function_list<void(const IChannel&, ...)>`. Callsites that fire events pass `*this` which upcasts implicitly via the new inheritance. - Test/doc lambdas migrated: tests/fastled_core.cpp EventTracker stores `const IChannel*`; lambdas in fastled_core.cpp, fl/channels/driver.cpp, fl/chipsets/ucs7604.cpp updated. README and FastLED.h docstrings refreshed. Also fixes pre-existing KBI checker failures in test.py (lines 186/193/211) flagged by lint -- the test-lock fix from #2432 introduced try-except blocks catching Exception without KeyboardInterrupt re-raise. Added the standard `except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki)` clause before each `except Exception`. Per CodeRabbit feedback on PR #2435, the cleanup intentionally suppresses (does NOT re-raise) KeyboardInterrupt because: - _release_held_build_locks() is best-effort cleanup called by deadman_timer and watchdog_timer, both of which call os._exit() unconditionally afterward. - Re-raising would short-circuit the os._exit() and defeat the watchdog. Verification: - bash lint clean. - bash test --cpp passes (303/303). - ChannelEvents tests verified: pointer-identity comparisons `tracker.mLastChannel == channel.get()` still work because Channel inherits from IChannel (implicit upcast). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…3a of #2428) Adds a non-template polymorphic anchor `fl::IChannel` so ChannelEvents callbacks keep working after `Channel<Bus, Chipset>` becomes a template in Phase 3b. Pure API surface refactor -- no behavior changes. - New: src/fl/channels/ichannel.h. Minimal ABC with virtual `id()` and `name()`, noexcept special members, non-copyable/movable. Holds the public surface that any callback might reasonably want. - Channel now derives from CPixelLEDController<RGB> AND IChannel; existing `id()` / `name()` accessors marked `override`. - ChannelEvents callbacks change from `function_list<void(const Channel&, ...)>` to `function_list<void(const IChannel&, ...)>`. Callsites that fire events pass `*this` which upcasts implicitly via the new inheritance. - Test/doc lambdas migrated: tests/fastled_core.cpp EventTracker stores `const IChannel*`; lambdas in fastled_core.cpp, fl/channels/driver.cpp, fl/chipsets/ucs7604.cpp updated. README and FastLED.h docstrings refreshed. Also fixes pre-existing KBI checker failures in test.py (lines 186/193/211) flagged by lint -- the test-lock fix from #2432 introduced try-except blocks catching Exception without KeyboardInterrupt re-raise. Added the standard `except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki)` clause before each `except Exception`. Per CodeRabbit feedback on PR #2435, the cleanup intentionally suppresses (does NOT re-raise) KeyboardInterrupt because: - _release_held_build_locks() is best-effort cleanup called by deadman_timer and watchdog_timer, both of which call os._exit() unconditionally afterward. - Re-raising would short-circuit the os._exit() and defeat the watchdog. Verification: - bash lint clean. - bash test --cpp passes (303/303). - ChannelEvents tests verified: pointer-identity comparisons `tracker.mLastChannel == channel.get()` still work because Channel inherits from IChannel (implicit upcast). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…3a of #2428) (#2435) Adds a non-template polymorphic anchor `fl::IChannel` so ChannelEvents callbacks keep working after `Channel<Bus, Chipset>` becomes a template in Phase 3b. Pure API surface refactor -- no behavior changes. - New: src/fl/channels/ichannel.h. Minimal ABC with virtual `id()` and `name()`, noexcept special members, non-copyable/movable. Holds the public surface that any callback might reasonably want. - Channel now derives from CPixelLEDController<RGB> AND IChannel; existing `id()` / `name()` accessors marked `override`. - ChannelEvents callbacks change from `function_list<void(const Channel&, ...)>` to `function_list<void(const IChannel&, ...)>`. Callsites that fire events pass `*this` which upcasts implicitly via the new inheritance. - Test/doc lambdas migrated: tests/fastled_core.cpp EventTracker stores `const IChannel*`; lambdas in fastled_core.cpp, fl/channels/driver.cpp, fl/chipsets/ucs7604.cpp updated. README and FastLED.h docstrings refreshed. Also fixes pre-existing KBI checker failures in test.py (lines 186/193/211) flagged by lint -- the test-lock fix from #2432 introduced try-except blocks catching Exception without KeyboardInterrupt re-raise. Added the standard `except KeyboardInterrupt as ki: handle_keyboard_interrupt(ki)` clause before each `except Exception`. Per CodeRabbit feedback on PR #2435, the cleanup intentionally suppresses (does NOT re-raise) KeyboardInterrupt because: - _release_held_build_locks() is best-effort cleanup called by deadman_timer and watchdog_timer, both of which call os._exit() unconditionally afterward. - Re-raising would short-circuit the os._exit() and defeat the watchdog. Verification: - bash lint clean. - bash test --cpp passes (303/303). - ChannelEvents tests verified: pointer-identity comparisons `tracker.mLastChannel == channel.get()` still work because Channel inherits from IChannel (implicit upcast). Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Fixes #2430.
bash test --cppcould leave a hung Python process holding thelibfastled_buildSQLite lock past the 600s watchdog, blocking every subsequent test invocation for 120s.Changes
test.py): a second daemon fires at_TIMEOUT_EVERYTHING + 60sand unconditionally callsos._exit(3)— the primary watchdog can wedge insidedump_thread_stacks()/psutil queries; the deadman bypasses all diagnostics so the process always dies on time.libfastled_buildlocks held by this PID before exiting.build_lock.py):_check_stale_locknow also breaks locks whose holder has held pastFASTLED_LOCK_MAX_HOLD_S(default 3600s — well above the longest legitimate hold including 2700s sequential debug-sanitizer builds).taskkill /F /PID N(Windows) orkill -9 N(Unix), plus a pointer tolock_admin --clean-stale.bash test --cpp 2>&1 | tail -15zero-byte symptom — when stdout is not a TTY, force line buffering so each\n-terminated line surfaces immediately.Test plan
uv run pytest ci/tests/test_build_lock_wedged_steal.py— 2 new tests pass (positive + negative wedged-steal cases)uv run pytest ci/tests/test_stale_lock_recovery.py ci/tests/test_lock_database.py ci/tests/test_cache_lock.py— 32 existing lock tests pass (no regressions)bash lint— cleanbash test --list-tests— startup smoke test OKNotes on design
_TIMEOUT_EVERYTHING = 600and the timeout-bumping logic untouched. The deadman is purely additive insurance.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests