Skip to content

buffer_bounds_probe: refuse an unusable --json up front; a failed write is one error line - #6203

Closed
Koro4e wants to merge 2 commits into
ItsNotRexed:mainfrom
Koro4e:buffer-bounds-json
Closed

Koro4e wants to merge 2 commits into
ItsNotRexed:mainfrom
Koro4e:buffer-bounds-json

Conversation

@Koro4e

@Koro4e Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Finding + claim in the coordination issue: tools/buffer_bounds_probe.py:236 (args.json_out) wrote the report with no guard.

The folder is refused right after parse_args (before even --self-test), and the write is wrapped: one ERROR: cannot write ... line, exit 2. Testable with no GPU because the guard runs before the oracle is opened.

Tested

  • python -m pytest tests/test_buffer_bounds_probe.py -q: all pass, including the new folder refusal test (subprocess, no GPU needed).
  • Negative control: with main's tool the new test fails (the self-test/oracle path ran first).

Two commits: the tool, then the test. Windows 11, Python 3.12.10, CPU only. No game files. AI-assisted.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator changes.)

…e a failed write one error line (finding in the coordination issue, claim 7102450817)
@AsgerCode

Copy link
Copy Markdown

Tested 17c163f on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): fail, superseded by #6812 (merged today), and the branch now conflicts with main.

What I ran:

  • python -I tests/test_buffer_bounds_probe.py on the PR head: 4 tests, OK.
  • Negative control (merge base's tools/buffer_bounds_probe.py, PR tests): the new folder test fails, 77 != 2. The test catches the old code.
  • Merge with current main (ae12372e): conflict in tools/buffer_bounds_probe.py. buffer_bounds_probe: refuse a --json it cannot write before the GPU sweep, and one ERROR line when the write fails (EGEN-BUFFERBOUNDS-JSON-OUT) #6812 (399f621b, "refuse a --json it cannot write before the GPU sweep, and one ERROR line when the write fails") changed the same two places: the up-front --json guard and the try/except OSError around the write.
  • main's tests against the PR tool: test_json_in_a_missing_folder_is_refused_before_the_gpu_run fails, 77 != 2.
  • The PR's new test against main's tool: fails only on the message text. main prints ERROR: --json <path> is a directory, and the test looks for --json is a directory.

By hand, with no hardware oracle (LEONIDA_AMD_CLANG set to a missing file):

Input PR head main
--json <folder> exit 2, ERROR: --json is a directory, not a report file: ... exit 2, ERROR: --json ... is a directory
--json <tmp>/missing/r.json exit 77 (the oracle path runs; on a GPU the sweep runs and only the write fails) exit 2, ERROR: --json ...: its folder ... does not exist
--self-test --json <folder> exit 2 exit 0 (the self-test writes no report)

So the title's "refuse an unusable --json up front" covers only a folder. A path in a missing folder still gets the full GPU sweep before the error. main already refuses both cases before the sweep. I suggest closing this PR as a duplicate of #6812.

Overlap: #4785 ("report JSON write failures cleanly") and #5406 ("validate and write --json through the shared helpers") are still open on the same lines. Both conflict with this PR and with main.

AI-assisted (Claude Code).

@Koro4e

Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main's tools/buffer_bounds_probe.py already refuses an unusable --json up front - a path that is a directory, a folder that does not exist, and a failed write each print one ERROR line to stderr (the --json guard block on main). Verified locally against origin/main with git merge-tree plus a direct read of the file. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants