Repository navigation
Description
Summary
bash test --cpp can leave a previous test process hung indefinitely while holding the libfastled_build SQLite lock, blocking every subsequent test invocation for 120 s before timing out with a "lock blocked" diagnostic. Two related observations:
- Lock-holder runs past the watchdog timeout.
test.pydeclares_TIMEOUT_EVERYTHING = 600(10 minutes), but in this session a test process (python.exePID 26892) was observed holding the lock for 803 s (~13.5 min) and was still alive — the watchdog/force-exit either never fired or failed to release the lock. - Backgrounded invocations can complete with zero captured output despite exit 0. Running
bash test --cpp 2>&1 | tail -15in the background produces a zero-byte output file even when the underlying build/test succeeded. Likely cause:tail -15only sees\n-terminated lines, but the test runner emits ANSI progress bars using\roverwrites; when stdout is piped (not a TTY), the renderer may emit no\n-terminated content, sotailcaptures nothing.
The combination is painful: a backgrounded bash test --cpp appears to hang silently (no output), and once it eventually exits, subsequent foreground runs block for 120 s waiting for a stale lock that the watchdog should have cleared.
Reproduction
Tested on Windows 10, bash shell (Git for Windows), master HEAD ebb48e610f plus a Phase 2 channels refactor branch with ~25 modified/added files (mostly per-platform bus_traits.h headers and edits to driver _build.cpp.hpp unity-build aggregators).
# 1) Clean tree, on a feature branch with ~25 pending changes.
git status
# 2) First test run completes normally (~25-90 s for incremental, full).
bash test --cpp # passes 303/303 or 221/221 depending on fingerprint cache state
# 3) Second test run, this time backgrounded by a tool harness with the same
# pipe-to-tail pattern that long-running task wrappers use.
# Reproduce with the equivalent shell command:
bash test --cpp 2>&1 | tail -15 > /tmp/output.log &
BGPID=$!
wait $BGPID
echo "exit=$?"
wc -c /tmp/output.log
# Observed: exit=0, /tmp/output.log size=0 bytes. The build/test "succeeded"
# but no captured stdout, so no way to tell whether 0/0 or 303/303 ran.
# 4) Subsequent foreground run blocks for 120 s, then dumps stacks:
bash test --cpp
# After ~120 s:
# [MESON] Failed to acquire libfastled build lock after 120s.
# Held by: PID <N> (held 600s+, name=python.exe, exe=...python.exe,
# cmd=...test.py --cpp)
# [LOCK] Blocked on 'build:libfastled_build' for 2s - dumping stacks:
# 5) Manual recovery (Windows):
taskkill //PID <N> //FIn this session the held duration of the stuck process was 803 s, well past _TIMEOUT_EVERYTHING = 600 set in test.py:79.
Files / code paths likely involved
test.py:79—_TIMEOUT_EVERYTHING = 600(10 min watchdog).test.py:77—_CANCEL_WATCHDOG = threading.Event()(cancellation signal).ci/util/build_lock.py:28—LOCK_TIMEOUT_S = 120.0lock-acquisition timeout.ci/util/build_lock.py:35-69— process-alive checks viapsutil.ci/util/test_env.py—dump_thread_stacks,setup_force_exitwatchdog wiring.- The
bash testwrapper is justuv run test.py "$@".
Suggested fixes (in priority order)
High — make the watchdog actually kill the process
_TIMEOUT_EVERYTHING = 600 should be a hard wall. If the test main thread is past 600 s, the watchdog should:
- Dump thread stacks once.
- Release any held SQLite locks via the existing
build_lockcleanup hooks. os._exit(<nonzero>)to bypass any blocked atexit handlers / hung join().
The current setup (_TIMEOUT_EVERYTHING + setup_force_exit in test_env.py) is not reliably terminating runaway test processes. Consider:
- Sending
signal.SIGABRTfrom a daemon thread before falling back toos._exit(). - Verifying the watchdog thread itself is daemonized so it can't be silently joined out by the main thread's exit machinery.
- A second-tier "deadman" timer at
_TIMEOUT_EVERYTHING + 60sthat doesos._exit()unconditionally.
High — release libfastled_build lock when the holder dies
The build_lock already has PID-based stale-lock detection (_is_process_alive_psutil), but waited 120 s before checking and emitting diagnostics for a process that was alive but hung. Add:
- An "alive but unresponsive" detection: if the holder PID has been holding the lock past
_TIMEOUT_EVERYTHING + 30s, treat the lock as stale and steal it (with a loud warning). - Or: have the holder's watchdog explicitly release the lock before force-exit.
Medium — fix the silent-pipe issue
When stdout is not a TTY, the test runner should suppress ANSI progress bars (or replace \r-overwrites with newline-terminated periodic status lines) so that bash test --cpp 2>&1 | tail -15 captures something useful — even just the final summary.
isatty() check on stdout at startup, switching the renderer to plain-line mode when piped, would be the standard fix.
Low — surface a clear error from the lock-blocking path
The current error is good (Held by: PID 26892 (held 803s, name=python.exe, ...)) but doesn't suggest a remedy. Add a one-line hint:
Tip: if the holder appears stuck, run: taskkill /PID 26892 /F (Windows)
kill -9 26892 (Linux/macOS)
Impact
- Developer flow: silent hangs in agent-driven CI workflows that wrap test runs in a 10-minute timeout (the test exits silently with empty captured output, the agent moves on, the next test hangs 120 s on the stale lock).
- CI: a single hung test can block all subsequent test invocations on the same machine for the lifetime of the lock holder.
- Debuggability: no captured stdout from the hung process means there's no way to tell what the test was doing when it hung.
Environment
- OS: Windows 10 Pro 10.0.19045
- Shell: bash (Git for Windows)
- Python: 3.13.1 (uv-managed venv)
- Repro branch:
feat/channels-bus-traits-drivers(offmasterebb48e6), with ~25 file changes (Phase 2 of feat(channels): compile-time Bus binding via templated ChannelConfig (eliminates Channel API binary bloat) #2428). - Same symptom is plausible on Linux/macOS — the lock and watchdog logic is platform-agnostic.
Activity
fix(test): deadman watchdog + steal wedged libfastled_build locks (#2430