Scripts: harden check_layout CLI, DXBC validation, and error handling #2151
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2151
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2151"
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?
@HumanlyDev on GitHub · 2026-11-25 06:24 UTC · original
HumanlyDev:scripts/harden-check-layout→main· +338 −21 · 2 files · 1 commits · openHarden
scripts/re/check_layout.pyso malformed/non-DXBC files, DXBC blobs withoutRTS0, subdirectories, disassembler errors, off-boundary loads, and missing/invalid CLI arguments are handled cleanly instead of crashing or silently passing, and add unit tests inscripts/test_check_layout.py. Non-runtime change underscripts/.What is in it
scripts/re/check_layout.py:if __name__ == '__main__':(parse_args,check_listing,main) with<dir> [--xcl <path>]argument validation.b'DXBC'magic and chunk/RTS0 bounds inparts()andlayout(), skip subdirectories and non-.dxbcfiles, handlers is Nonecleanly, and read files withwith open(...).xclbinary exists andsubprocess.runexits0, and return exit code1when off-boundary loads (bad > 0) or disassembler errors occur.scripts/test_check_layout.py:parts/layout(with/withoutRTS0, non-DXBC, truncated containers), directory scanning with subdirs/non-.dxbc/invalid.dxbc, mockedxcl disasmfailures and missing--xcl, on-boundary vs off-boundarys_load_dworddetection, and CLI argument error handling.Tested
32.0.16.1088), AMD Ryzen 5 7600, Windows 11 Pro10.0.26200(build26200), Python3.14.6,rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.8.2502.11.python -m unittest scripts/test_check_layout.py -v: 8 passed, 0 failed (OKin 0.218s)..\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4, RTX 4060, debug): 1154 passed, 0 failed, 46 ignored across 21 targets (25 SKIPPED GPU checks: 20no wave64, 3per-lane form#1426refusals, 1no heap windows, 1cannot disable the driver cache (Windows Developer Mode is required)).Regression run
scripts/(no runtime files undercrates/xcl/src/modified).Not tested
scripts/re/check_layout.pyagainst a live directory of extractedbvhb_shaders.py.dxbcfiles (not present on this machine), retail titles /XCL_SAMPLE_*, AMD RDNA3/4, Linux / Wine.AI use
scripts/re/check_layout.py, wrote the hardening changes andscripts/test_check_layout.py, ran the unit tests and workspace suite, and drafted this PR description.@DavidM1911 on GitHub · 2026-11-25 07:04 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 10:46 UTC · original
Diff audited (
scripts/re/check_layout.pybounds checks +test_check_layout.py) and CI workflow approved (running). NeedsBuild and testgreen plus independent test verification.@raylitebull on GitHub · 2026-11-25 18:28 UTC · original
Review note on
aa825c0:@RavenCurseBurgnoted thatscripts/re/check_layout.pymisses zero-offsets_load_dword ..., nullspellings (emitted by XCL's formatter and LLVM AMDGPU examples). Addressing that plus getting independent verification oftest_check_layout.pywill unblock merge.@RavenCurseBurg on GitHub · 2026-11-25 11:43 UTC · original · edited 2026-11-26 10:39 UTC
I compared this head (
aa825c088e65db380f67a112e0474e56ea841b6a) with #1088 using a native disassembler stand-in and the same two synthetic shader files. Both reported stderr, but a child that exited 23 with a stdout-only diagnostic lost its message here. A one-line follow-up and regression assertion retain stdout when stderr is empty. The batch still checks the second file, counts its successful load and exits 1. Stderr still takes precedence; a silent failure retains the numeric fallback. Five native cases passed on the candidate, including an all-success control. The new assertion failed on the original script; with the fix,python -B -m unittest discover -s scripts -p "test_*.py"passed 33/33. The eight focused tests also passed when combined locally with the earlier null-offset candidate931c40a. Windows 11, Core i7-13700, Python 3.14.3; no retail shaders or GPU work. OpenAI Codex (GPT-6) prepared the fix and ran the checks.Earlier verification
Tested
aa825c088e65db380f67a112e0474e56ea841b6aon Windows 11 24H2 (26100.9711), i7-13700, Python 3.14.3.Tested
python -B -m unittest discover -s scripts -p test_check_layout.pypassed all 8 tests (0 failures, 0 skips).scripts/re/check_layout.py <fixture-dir> --xcl <fixture-disasm.cmd>on a synthetic root signature with one 8-byte CBV at offset 0. The stand-in printed the pointer-copy instructions and one scalar load. Offsets0x0and0x4each counted as one on-boundary load (exit 0). Offset0x8counted as one off-boundary load (exit 1).s_load_dword s5, s[2:3], null, the checker reported 0 on, 0 off (exit 0). This exact load is in the tracked LLVM example, and XCL's formatter emitsnullfor this case.nullthen counted as one on-boundary load and the other three results stayed the same.Not tested
Actual XCL disassembly, retail shader inputs or the Rust/GPU workspace suite.
AI use
OpenAI Codex (GPT-6) ran the tests, wrote the CLI fixture and follow-up patch, and prepared this report.
Follow-up on the review at
aa825c088e65. Tested candidate 23825658d. A directory containing only a four-byteDXBCfile previously returned 0. The candidate returned 1 and reported that no valid container remained, without invoking disassembly. The existing mixed batch with a valid container lackingRTS0and an invalid file still passed. All 34 script tests passed.Command on the candidate:
python -B -m unittest discover -s scripts -p "test_*.py". Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the patch and ran the tests with synthetic inputs. I did not run the full Rust/GPU suite.@luckyteagirl on GitHub · 2026-11-26 10:06 UTC · original · reviewed
On
aa825c0, a directory whose only.dxbcfile is malformed now exits 0 after validating nothing. I reproduced this with a four-bytebad.dxbccontaining onlyDXBCand an existing stand-in--xclexecutable that was never called. This head printedskipping invalid DXBC (not a DXBC container)andloads on parameter boundaries: 0, off: 0, then exited 0; the PR base and current main exited 1 on the same input. The new catch skips the file without incrementingerrors, so an all-invalid batch appears green. The existing mixed-file fixture expects success despite a corrupt file, which leaves the intended contract for an all-invalid directory unclear.Could the script distinguish malformed inputs from valid files that simply lack
RTS0, and fail when no checkable file remains (or count malformed.dxbcfiles as validation errors if that is the intended policy)? A malformed-only fixture should pin down the exit status while the scanner still continues through a mixed batch. This was an exact-head CPU-only differential; no GPU shader disassembly ran.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.