check_d3d12_trace: finish communicate() after killing a timed-out fixture (OLD-9920) #1330

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

@⁠fin-github on GitHub · 2026-11-24 21:58 UTC · original
fin-github:takeover/old-9920-d3d12-trace-timeout → main · +54 −12 · 2 files · 2 commits · open

Claimed in the coordination issue as: OLD-9920 (#14)

Supersedes draft #188, carried over from old upstream PR 9920 in the original repository. This is the same change cherry-picked onto current main (git cherry-pick -x), with the original author (Sunkiller-qc) kept on every commit. The change and its explanation are theirs; see #188 for the original description.

Tested

Windows 11 Pro 26200, CPython 3.14.4, on main 4a50cafc7. No GPU, no game files.

  • On this branch: tests/test_check_d3d12_trace.py: 4 tests OK (1 skipped), 4.6 s
  • The same test file(s) with main's code: test_runner_timeout_does_not_wait_for_a_child_holding_the_output fails (32 s run), so the tests still catch the bug on current main.
  • scripts/check_no_game_data.py on the changed files and tests/test_text_write_line_endings.py: clean.

GPUs tested: n/a

AI-assisted: yes (Claude Code). The cherry-pick and the test runs were done by the agent; the code is the original author's.

**@⁠fin-github** on GitHub · 2026-11-24 21:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1330) `fin-github:takeover/old-9920-d3d12-trace-timeout` → `main` · +54 −12 · 2 files · 2 commits · open Claimed in the coordination issue as: `OLD-9920` (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) Supersedes draft #188, carried over from old upstream PR 9920 in the original repository. This is the same change cherry-picked onto current `main` (`git cherry-pick -x`), with the original author (Sunkiller-qc) kept on every commit. The change and its explanation are theirs; see #188 for the original description. ### Tested Windows 11 Pro 26200, CPython 3.14.4, on `main` 4a50cafc7. No GPU, no game files. - On this branch: `tests/test_check_d3d12_trace.py`: 4 tests OK (1 skipped), 4.6 s - The same test file(s) with `main`'s code: `test_runner_timeout_does_not_wait_for_a_child_holding_the_output` fails (32 s run), so the tests still catch the bug on current `main`. - `scripts/check_no_game_data.py` on the changed files and `tests/test_text_write_line_endings.py`: clean. GPUs tested: n/a AI-assisted: yes (Claude Code). The cherry-pick and the test runs were done by the agent; the code is the original author's.
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.

(cherry picked from commit 0b7b8fe631)
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.

(cherry picked from commit cc2e281959)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:47:38 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-24 23:36 UTC · original

Independent verification (AI-assisted, overnight review batch):

  • Checked out 6240af0; diff reworks run_fixture in runtime/test/check_d3d12_trace.py to capture stdout/stderr in tempfile.TemporaryFiles instead of pipes, wait(timeout), and a new kill_tree (killpg on POSIX-with-runner, taskkill /F /T on Windows, process.kill() otherwise).
  • Bug repro confirmed on origin/main: same synthetic runner+grandchild scenario — main's version blocked ~20 s (waited for the pipe-holding child to exit) before reporting the timeout; the PR branch reports no exit within 2s at ~the limit.
  • python -I -m pytest tests/test_check_d3d12_trace.py: 3 passed + 1 skipped (POSIX-only) in 6.4 s on rerun.
  • check_no_game_data.py on both changed files: clean. compileall clean.
  • Caveats observed on this machine (Windows 11, CPython 3.14.4, Defender active):
    • The new test test_runner_timeout_does_not_wait_for_a_child_holding_the_output is timing-sensitive: one run measured 15.39 s vs its assertLess(elapsed, 15) bound and flaked a TemporaryDirectory teardown (orphaned grandchild briefly locks the dir). A rerun passed in 6.4 s. If taskkill exceeds its internal 5 s timeout under load, the grandchild can be orphaned — the check itself still exits on time, so this is a test-robustness note, not a correctness bug.
    • Verified directly that taskkill /F /T /PID does kill the whole tree when it completes (child PID terminated along with the launcher).
  • No GPU, no game files, no Wine needed. LGTM with the flakiness note above.
**@⁠whoalin1** on GitHub · 2026-11-24 23:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1330#issuecomment-7147596510) Independent verification (AI-assisted, overnight review batch): - Checked out 6240af0; diff reworks `run_fixture` in `runtime/test/check_d3d12_trace.py` to capture stdout/stderr in `tempfile.TemporaryFile`s instead of pipes, `wait(timeout)`, and a new `kill_tree` (killpg on POSIX-with-runner, `taskkill /F /T` on Windows, `process.kill()` otherwise). - Bug repro confirmed on `origin/main`: same synthetic runner+grandchild scenario — main's version blocked ~20 s (waited for the pipe-holding child to exit) before reporting the timeout; the PR branch reports `no exit within 2s` at ~the limit. - `python -I -m pytest tests/test_check_d3d12_trace.py`: 3 passed + 1 skipped (POSIX-only) in 6.4 s on rerun. - `check_no_game_data.py` on both changed files: clean. compileall clean. - Caveats observed on this machine (Windows 11, CPython 3.14.4, Defender active): - The new test `test_runner_timeout_does_not_wait_for_a_child_holding_the_output` is timing-sensitive: one run measured 15.39 s vs its `assertLess(elapsed, 15)` bound and flaked a TemporaryDirectory teardown (orphaned grandchild briefly locks the dir). A rerun passed in 6.4 s. If taskkill exceeds its internal 5 s timeout under load, the grandchild can be orphaned — the check itself still exits on time, so this is a test-robustness note, not a correctness bug. - Verified directly that `taskkill /F /T /PID` does kill the whole tree when it completes (child PID terminated along with the launcher). - No GPU, no game files, no Wine needed. LGTM with the flakiness note above.
Author
Owner

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

Thanks! For reference, #1338 has a byte-identical diff (same two commits) and was opened a few minutes after this one, so this PR looks like the one to keep; maintainers can decide.

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/1330#issuecomment-7169187471) Thanks! For reference, #1338 has a byte-identical diff (same two commits) and was opened a few minutes after this one, so this PR looks like the one to keep; maintainers can decide. AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).
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/1330/head:github-bot/gh-1330'
git switch 'github-bot/gh-1330'

Merge

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