d3d12_device_calls: validate --out upfront and publish reports atomically #2262
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2262"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T11:35:43Z.
Claimed in the coordination issue as: D3D12-DEVICE-CALLS-UPFRONT-OUT-AND-ATOMIC-REPORTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7190884297)
What and why
tools/d3d12_device_calls.pypreviously read and scanned the PE image before validating--outorsame_report_path(...), and wrote<image>.device_calls.jsonand.txtdirectly in place withopen(..., "w"). An unusable--outor self-overwrite path wasted a full PE decode (or created an empty--outdirectory on unreadable images), and an interrupted or failing write could truncate or partially update the report pair.--out(non-empty and directory ancestors), input/report path collisions (same_report_path), and directory-occupied report paths before reading or scanning the input image, deferringos.makedirsuntil scan output is ready to write..jsonand.txtoutputs into UTF-8 LF temp files inside--out, copy/probe permissions viafile_mode.published_mode(...), replace both viareplace_retry.replace(...), and clean up any leftover staged files on error.--out/ collision / directory-target errors, unopened invalid images, and preservation of prior reports on staging failure.Tested
python -I tests/test_d3d12_device_calls.py -v(19 tests passed)upstream/mainbaseline negative control: failed with the new CLI tests before the fixpython -I tests/test_ci_registration.py,python -I tests/test_text_write_line_endings.py,python -I scripts/check_no_game_data.py,python -I -m compileall -q, andgit diff --cached --checkGPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T12:23:38Z.
Verified on main
a73a57e1(Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_d3d12_device_calls.py: 19 tests OK. The PR's test file against main's tool: 2 failures and 1 error, so the new tests fail on main and pass with the change. compileall clean.AI-assisted: yes (Claude Code)
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:36:47Z.
Review: APPROVED
Approving
6dd813ddb.--outand its existing ancestors are checked before the scan, and both reports are staged as temp files and replaced only once all are written.Merged onto
maind1dff7949in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_d3d12_device_calls.py: 19 passed (main: 15). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:35:16Z.
#2262 | head
6dd813ddb1(merged cleanly with main6c7f79343) |python -I tests/test_d3d12_device_calls.py| red on main:FAILED (failures=2, errors=1)(scanran before validating--out/ hardlink self-overwrite / directory report targets, and report writes were non-atomic) | green on PR+main:19 tests OK| Windows 11, Python 3.12.10 | AI-assisted: yesAudited
_check_out_dir_ancestors, upfrontsame_report_path+ directory-target checks before opening/scanning the PE image (avoiding empty--outcreation on invalid images and catching Windows 11 NTFSos.linkcollisions), and staged UTF-8 LF atomic publishing viapublished_mode+replace_retry.replaceintools/d3d12_device_calls.py. Also passedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T15:05:30Z.
Red/green: the PR tests fail on main
09c153948and pass on head6dd813ddb1(cloud 2).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)