check_d3d12_trace: capture fixture output in files so a timeout cannot wait for its children (OLD-9920) #1338

Open
github-bot wants to merge 2 commits from github-bot/gh-1338 into main AGit
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 22:00 UTC · original
ambroseautomation:carry/old-9920-check-d3d12-trace-timeout → main · +54 −12 · 2 files · 2 commits · open

Summary

Coordination item: OLD-9920 (carry-forward of old-pr/9920, preserving original author Sunkiller-qc across both commits).

Problem & Root Cause

In runtime/test/check_d3d12_trace.py, when a timed-out fixture was killed, calling communicate() on piped stdout/stderr could block indefinitely if a grandchild process inherited and kept the pipe handles open.

Implementation

  • Captures the fixture's stdout/stderr in temporary files rather than pipes in runtime/test/check_d3d12_trace.py and finishes waiting/cleanup after killing a timed-out fixture so grandchildren holding descriptors cannot block the runner.
  • Adds test_runner_timeout_does_not_wait_for_a_child_holding_the_output in tests/test_check_d3d12_trace.py.

Tests Run

Environment: Windows 11 Pro 64-bit, Python 3.12.10, synthetic fixtures only (no game data).

  • python -I -m py_compile runtime/test/check_d3d12_trace.py tests/test_check_d3d12_trace.py — PASS
  • pytest tests/test_check_d3d12_trace.py -v — 3 passed, 1 skipped (POSIX-only os.kill(pid, 0) check skipped on Windows; new test_runner_timeout_does_not_wait_for_a_child_holding_the_output PASSED)
  • python -I scripts/check_no_game_data.py runtime/test/check_d3d12_trace.py tests/test_check_d3d12_trace.py — PASS

Disclosure

AI-assisted: yes (carry-forward, rebase onto current main, and local verification; original implementation by Sunkiller-qc).

**@⁠ambroseautomation** on GitHub · 2026-11-24 22:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1338) `ambroseautomation:carry/old-9920-check-d3d12-trace-timeout` → `main` · +54 −12 · 2 files · 2 commits · open ## Summary Coordination item: `OLD-9920` (carry-forward of `old-pr/9920`, preserving original author `Sunkiller-qc` across both commits). ### Problem & Root Cause In `runtime/test/check_d3d12_trace.py`, when a timed-out fixture was killed, calling `communicate()` on piped stdout/stderr could block indefinitely if a grandchild process inherited and kept the pipe handles open. ### Implementation - Captures the fixture's stdout/stderr in temporary files rather than pipes in `runtime/test/check_d3d12_trace.py` and finishes waiting/cleanup after killing a timed-out fixture so grandchildren holding descriptors cannot block the runner. - Adds `test_runner_timeout_does_not_wait_for_a_child_holding_the_output` in `tests/test_check_d3d12_trace.py`. ## Tests Run Environment: Windows 11 Pro 64-bit, Python 3.12.10, synthetic fixtures only (no game data). - `python -I -m py_compile runtime/test/check_d3d12_trace.py tests/test_check_d3d12_trace.py` — PASS - `pytest tests/test_check_d3d12_trace.py -v` — 3 passed, 1 skipped (POSIX-only `os.kill(pid, 0)` check skipped on Windows; new `test_runner_timeout_does_not_wait_for_a_child_holding_the_output` PASSED) - `python -I scripts/check_no_game_data.py runtime/test/check_d3d12_trace.py tests/test_check_d3d12_trace.py` — PASS ## Disclosure AI-assisted: yes (carry-forward, rebase onto current `main`, and local verification; original implementation by Sunkiller-qc).
Follow-up to 433edaa. After a timeout the run called process.wait(), which
reaps the process but leaves the output pipes undrained. As the subprocess
documentation advises, finish with communicate() once the process is killed.
The call is bounded so a stray process that still holds the pipes (a runner
without its own process group) cannot hold the check past its limit.
Review of #9920 (thanks, Gevroska): on Windows a grandchild that inherits the
launcher's stdout/stderr pipes kept the check waiting past RUNNER_TIMEOUT,
on main and with the bounded communicate(), because leaving the Popen
context manager joins the pipe reader threads, which wait for every holder
of the pipes.

run_fixture no longer uses pipes: the output goes to two temporary files and
the run waits for the launcher alone, so no read can wait for a child. On a
timeout kill_tree() stops the process group on POSIX (as before) or the
process tree with taskkill /F /T on Windows, then the launcher is killed and
reaped with a bound. The files are read back as the pipes gave the text
(UTF-8 with replacements, \n line ends).

tests/test_check_d3d12_trace.py gains the reviewer's case: a launcher whose
child inherits its output and sleeps 30 s while the launcher sleeps 60 s,
with a 2 s limit; the check must fail with the one-line message within 15 s.
Not run here.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:47:56 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 15:00 UTC · original

Reviewed 865d357: ran python3 -I tests/test_check_d3d12_trace.py on the PR tree on Linux (4/4 pass) and on main with your test file copied in (4/4 pass too — on POSIX killpg kills the pipe-holding child, so the new test only discriminates on Windows). A probe with a runner that exits at ~1 s while a 30 s child inherits its output shows the fix matters on Linux as well: main fails fixture.exe: no exit within 5s at the deadline; this PR returns at ~1.1 s. Minor: read_output() maps CRLF→LF only, so a lone \r that the old pipes turned into \n now reaches the failure message raw (repro: sys.stderr.write('fixture output\r'); sys.exit(3)) — outcomes unchanged since splitlines() still splits on \r; at most a docstring tweak. The Windows hang and the coordination-item claim I could not verify here (no Windows, no GitHub access). AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 15:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1338#issuecomment-7166161765) Reviewed 865d357: ran `python3 -I tests/test_check_d3d12_trace.py` on the PR tree on Linux (4/4 pass) and on main with your test file copied in (4/4 pass too — on POSIX killpg kills the pipe-holding child, so the new test only discriminates on Windows). A probe with a runner that exits at ~1 s while a 30 s child inherits its output shows the fix matters on Linux as well: main fails `fixture.exe: no exit within 5s` at the deadline; this PR returns at ~1.1 s. Minor: `read_output()` maps CRLF→LF only, so a lone `\r` that the old pipes turned into `\n` now reaches the failure message raw (repro: `sys.stderr.write('fixture output\r'); sys.exit(3)`) — outcomes unchanged since `splitlines()` still splits on `\r`; at most a docstring tweak. The Windows hang and the coordination-item claim I could not verify here (no Windows, no GitHub access). AI-assisted review. **Recommendation:** Merge
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-25 17:13 UTC · original

Thanks for this. Its diff is identical to #1330 (same two commits, opened ~2 minutes earlier), so it seems to be a duplicate; leaving it to the maintainers to decide which one to keep.

AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).

**@⁠MoonEyes** on GitHub · 2026-11-25 17:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1338#issuecomment-7169192828) Thanks for this. Its diff is identical to #1330 (same two commits, opened ~2 minutes earlier), so it seems to be a duplicate; leaving it to the maintainers to decide which one to keep. AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).
Author
Owner

@⁠wavehs on GitHub · 2026-11-26 18:47 UTC · original

This is the same change as #1330 (fin-github, opened 2026-11-24 21:58, two minutes earlier): the two diffs are byte-identical (only blob hashes differ), same two files, both claim OLD-9920, and both preserve the original author. I applied #1330 to main f107ae044: clean apply and python3 -I tests/test_check_d3d12_trace.py is OK.

One of the two is redundant. #1330 is the earlier one and says it is the git cherry-pick -x of draft #188; I would keep that and close this, unless you two agree on the other order. No content difference either way.

AI-assisted (review/verification only).

**@⁠wavehs** on GitHub · 2026-11-26 18:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1338#issuecomment-7200862600) This is the same change as **#1330** (fin-github, opened 2026-11-24 21:58, two minutes earlier): the two diffs are byte-identical (only blob hashes differ), same two files, both claim OLD-9920, and both preserve the original author. I applied #1330 to `main` `f107ae044`: clean apply and `python3 -I tests/test_check_d3d12_trace.py` is `OK`. One of the two is redundant. #1330 is the earlier one and says it is the `git cherry-pick -x` of draft #188; I would keep that and close this, unless you two agree on the other order. No content difference either way. AI-assisted (review/verification only).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1338/head:github-bot/gh-1338'
git switch 'github-bot/gh-1338'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1338'
git switch 'github-bot/gh-1338'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1338'
git switch 'github-bot/gh-1338'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1338'
git switch 'main'
git merge --squash 'github-bot/gh-1338'
git switch 'main'
git merge --ff-only 'github-bot/gh-1338'
git switch 'main'
git merge 'github-bot/gh-1338'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.