Skip to content

BUILD-1938: reject malformed sandbox readbacks - #6008

Open
venetanji wants to merge 2 commits into
ItsNotRexed:mainfrom
venetanji:fix/sandbox-readback-validation
Open

venetanji wants to merge 2 commits into
ItsNotRexed:mainfrom
venetanji:fix/sandbox-readback-validation

Conversation

@venetanji

Copy link
Copy Markdown

Claimed in the coordination issue as: BUILD-1938, readback-validation slice of this three-part claim, carried into #5934.

Depends on: #4119, #4436 (their published shared-sandbox refactors overlap tools/sandbox.py; this patch builds independently on main).

What and why

sandbox.py --check can report success for an invalid renderer image. On current main, check_frame(path, False) returns true for both junk\n1 1\n255\n followed by one black pixel and P6\n0 0\n255\n with no pixels. Truncated readbacks can instead raise an exception.

Validate the renderer's P6/255 format, positive decimal dimensions and exact RGB payload length. Missing or malformed images now produce a failed check with a readable message. Compute the one-percent coverage threshold without rounding it down to zero for small images. This reads the format emitted by vk_sandbox, rather than implementing a general Netpbm reader.

Tested

Base 561b65a832218fbb9e6d2effd392a8eef093a3f8; patch head d333c58e73ebbdd35bacb8158edbb02e277f634f.

  • python -I -B tests/test_sandbox_frame.py -v: six tests pass, covering valid binary pixels, malformed/missing readbacks, clear-only frames, the coverage boundary and the 256-colour texture-detail boundary. The regression tests fail on the original implementation.
  • test_sandbox_pick.py (6), test_sandbox_scene.py (10), and test_text_write_line_endings.py (3) pass. git diff --check passes.
  • Tested together with the other BUILD-1938 slices, RT-432: cull forward-sandbox draws outside the camera frustum #5830 and vk_descriptor_bench, vk_sandbox: pick the GPU through LEONIDA_VK_DEVICE #5889 in a private integration checkout: all affected CPU/Python checks pass, and the synthetic culling Vulkan suite passes on RTX 3080 Ti and RTX 3090, NVIDIA 615.78.08, Arch Linux. This branch itself needs only Python; native Windows has not been run for these changes.

The three new slices merge cleanly with one another. This slice also merges cleanly with #5830; the integration checkout resolved the other slices' conflicts with that PR. All test inputs are original synthetic bytes/GLSL; no game files.

AI-assisted: yes, Codex.

Checklist

  • No game data, keys or decryption, including in logs or reports quoted here.
  • Translator contract update: not applicable; no translator rule changes.

@leozinhoszg

Copy link
Copy Markdown
Contributor

Tested d333c58e on Windows 11 Pro (26200), CPython 3.14.7, CPU only, no game files: pass with notes.

  • Ran tests/test_sandbox_frame.py (6 OK), plus test_sandbox_pick.py, test_sandbox_scene.py and test_text_write_line_endings.py (all OK). compileall and git diff --check are clean. The branch also merges cleanly with BUILD-1938: preserve existing images during sandbox checks #6009, and both PRs' tests pass on the merged tree.
  • Negative control: with main's tools/sandbox.py put back, 4 of the 6 tests fail (13 failures, 8 errors across the subtests): junk, P6 0 0 and short or long payloads are accepted, a missing file raises FileNotFoundError, and a 1x1 sky frame passes the coverage check. The two control tests still pass, as they should.
  • Mutations of the size check, the 255 check, the <= 0 check and the OSError catch each turn a test red. A synthetic directory passed as the frame now returns a clean FAIL instead of a PermissionError, which is what Windows raises (tools/sandbox.py:106-109).
  • Note for the merge: Depends on: #4119, #4436 lists two PRs this branch doesn't build on, and both already conflict with main. If those are only overlap notes, moving them out of the Depends on line keeps the merge from waiting on them.

AI-assisted.

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