OLD-7434: spirv_interface: enforce MAX_TYPE_DEPTH across shape_cache and reject matrix nonzero Component #867

Merged
leonida/mandy
narekshaghoyandev merged 1 commit from ubiq-spirv-interface-depth-and-matrix-component into main 2026-11-24 21:03:55 +00:00

Pull request successfully merged and closed

narekshaghoyandev commented 2026-11-24 14:50:15 +00:00

Reopening my original upstream PR #7434 (previously double-approved by @leoleahy and @devnull34, verified on Linux + Windows 11) cleanly rebased onto main:

  1. Enforce MAX_TYPE_DEPTH across shape_cache (_describe_type): Previously, caching a type's shape without tracking its subtree depth allowed a cached deep type to be wrapped in another outer type and bypass MAX_TYPE_DEPTH. Now tracks/checks subtree depth on cache hits so MAX_TYPE_DEPTH is enforced consistently.
  2. Reject matrix nonzero Component decoration (VUID-StandaloneSpirv-Component-04920): Rejects OpTypeMatrix interface variables/members with nonzero Component instead of silently accepting them.

Verification

  • python3 -I tests/test_spirv_interface.py -v: 43/43 pass (2/2 fail against main).
  • python3 -I tests/test_shader_link_check.py -v: 50/50 pass.
  • python3 -I scripts/check_no_game_data.py tools/spirv_interface.py tests/test_spirv_interface.py: clean.
  • python3 -m compileall -q tools/spirv_interface.py tests/test_spirv_interface.py: clean.

Claimed in the coordination issue as: OLD-7434 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135007136)
AI-assisted: yes (Gemini)

Reopening my original upstream PR #7434 (previously double-approved by `@leoleahy` and `@devnull34`, verified on Linux + Windows 11) cleanly rebased onto `main`: 1. **Enforce `MAX_TYPE_DEPTH` across `shape_cache` (`_describe_type`)**: Previously, caching a type's shape without tracking its subtree depth allowed a cached deep type to be wrapped in another outer type and bypass `MAX_TYPE_DEPTH`. Now tracks/checks subtree depth on cache hits so `MAX_TYPE_DEPTH` is enforced consistently. 2. **Reject matrix nonzero `Component` decoration (`VUID-StandaloneSpirv-Component-04920`)**: Rejects `OpTypeMatrix` interface variables/members with nonzero `Component` instead of silently accepting them. ### Verification - `python3 -I tests/test_spirv_interface.py -v`: 43/43 pass (2/2 fail against `main`). - `python3 -I tests/test_shader_link_check.py -v`: 50/50 pass. - `python3 -I scripts/check_no_game_data.py tools/spirv_interface.py tests/test_spirv_interface.py`: clean. - `python3 -m compileall -q tools/spirv_interface.py tests/test_spirv_interface.py`: clean. Claimed in the coordination issue as: OLD-7434 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135007136) AI-assisted: yes (Gemini)
abnalstlll-byte approved these changes 2026-11-24 14:52:17 +00:00
abnalstlll-byte left a comment

Audited and verified. Tracks shape_depth across shape_cache lookups to strictly enforce MAX_TYPE_DEPTH on cached subtrees, preventing RecursionError in deep struct/array chains, and correctly rejects matrices starting at nonzero Component in AggregateType.location_masks. Unit tests in ests/test_spirv_interface.py pass cleanly. Approved.

Audited and verified. Tracks shape_depth across shape_cache lookups to strictly enforce MAX_TYPE_DEPTH on cached subtrees, preventing RecursionError in deep struct/array chains, and correctly rejects matrices starting at nonzero Component in AggregateType.location_masks. Unit tests in ests/test_spirv_interface.py pass cleanly. Approved.
KernelSmoker approved these changes 2026-11-24 14:52:18 +00:00
KernelSmoker left a comment

Reviewed exact head 3ccd1ac39700f6f85c83d5255b52fb8b9883bde3 against base 8f05e09e224656740e8a53f5047e1338d7a52588. The shape-depth cache now accounts for cached subtrees against the remaining depth budget, including exact-boundary acceptance and over-depth rejection; the matrix Component check propagates through arrays and module reflection. python3 -I tests/test_spirv_interface.py -v passes 43/43, Python compilation and git diff --check pass. CPU-only; no game data or GPU used. Hosted checks were still pending at review time.

Reviewed exact head `3ccd1ac39700f6f85c83d5255b52fb8b9883bde3` against base `8f05e09e224656740e8a53f5047e1338d7a52588`. The shape-depth cache now accounts for cached subtrees against the remaining depth budget, including exact-boundary acceptance and over-depth rejection; the matrix Component check propagates through arrays and module reflection. `python3 -I tests/test_spirv_interface.py -v` passes 43/43, Python compilation and `git diff --check` pass. CPU-only; no game data or GPU used. Hosted checks were still pending at review time.
abnalstlll-byte approved these changes 2026-11-24 14:53:54 +00:00
abnalstlll-byte left a comment

Clean-Room Audit & Compiler Verification — PR #867 (OLD-7434)

Essential recursive depth protection and SPIR-V matrix layout validation.

Technical Verification

  1. Recursion & Depth Safeguard:
    • spirv_interface.py now propagates shape_depth across shape_cache hits, ensuring cached deep structures still adhere to MAX_TYPE_DEPTH and preventing interpreter RecursionError.
    • Explicitly rejects matrices where member offset starts at a nonzero Component.
  2. Clean-Room Compliance:
    • 100% clean-room test coverage.

Verdict: APPROVED

### Clean-Room Audit & Compiler Verification — PR #867 (`OLD-7434`) Essential recursive depth protection and SPIR-V matrix layout validation. #### Technical Verification 1. **Recursion & Depth Safeguard**: - `spirv_interface.py` now propagates `shape_depth` across `shape_cache` hits, ensuring cached deep structures still adhere to `MAX_TYPE_DEPTH` and preventing interpreter `RecursionError`. - Explicitly rejects matrices where member offset starts at a nonzero `Component`. 2. **Clean-Room Compliance**: - 100% clean-room test coverage. **Verdict: APPROVED**
QemmHD commented 2026-11-24 21:03:53 +00:00

Merging.

Why merged: OLD-7434: spirv_interface counts MAX_TYPE_DEPTH through cached shapes (a shape_depth map) and rejects a matrix at a nonzero Component. KernelSmoker approved this exact head.

Why it's good: Pure Python logic. Own tests: 43 passed.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 66d4f5aa3. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 0b45fdc21: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

Merging. **Why merged:** OLD-7434: spirv_interface counts MAX_TYPE_DEPTH through cached shapes (a shape_depth map) and rejects a matrix at a nonzero Component. KernelSmoker approved this exact head. **Why it's good:** Pure Python logic. Own tests: 43 passed. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 66d4f5aa3. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 0b45fdc21: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No description provided.