[PR #879] OLD-7594: bvh_packing_check: fix bvh4-chunk continuation joining and NaN/Inf root checks #915

Open
opened 2026-11-26 20:19:29 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/879
Author: @narekshaghoyandev
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: ubiq-bvh-packing-check-continuations-and-nan


📝 Commits (1)

  • 4b32bdc bvh_packing_check: fix bvh4-chunk continuation joining and NaN/Inf root checks

📊 Changes

2 files changed (+104 additions, -7 deletions)

View changed files

📝 tests/test_bvh_packing_check.py (+78 -0)
📝 tools/bvh_packing_check.py (+26 -7)

📄 Description

Reopening my original upstream PR #7594 (refined per @Envyre and @kapitche's reviews), cleanly rebased onto main:

  1. Harden bvh4-chunk continuation joining (scan_window):
    • Skips false-positive ZHDR bytes in padding only within a bounded 16-byte slop (prev_end + 16) after a failed _inflate, so a damaged continuation stops cleanly as short_input instead of skipping ahead to glue an unrelated later raw stream.
    • Stops continuation joining on any non-raw stream (more_kind != "raw", including XML streams).
    • Defers recording continuation counts and consumed offsets until the joined stream actually reaches declared_bytes, so failed joins do not steal unrelated streams.
  2. Catch NaN/Inf in root bounds comparisons (_root_equal, union check): Rejects NaN anywhere in root bounds or child union (min([0.0, nan]) silently returned 0.0) and rejects infinite vs finite BOX32 bounds.

Verification

  • python3 -I tests/test_bvh_packing_check.py -v: 33/33 pass (both new tests fail against main).
  • python3 -I scripts/check_no_game_data.py tools/bvh_packing_check.py tests/test_bvh_packing_check.py: clean.
  • python3 -m compileall -q tools/bvh_packing_check.py tests/test_bvh_packing_check.py: clean.

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/879 **Author:** [@narekshaghoyandev](https://github.com/narekshaghoyandev) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `ubiq-bvh-packing-check-continuations-and-nan` --- ### 📝 Commits (1) - [`4b32bdc`](https://github.com/ubiquitarianism/leonida/commit/4b32bdc85fe14f9afe40a9edc14453d0435eff7d) bvh_packing_check: fix bvh4-chunk continuation joining and NaN/Inf root checks ### 📊 Changes **2 files changed** (+104 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_bvh_packing_check.py` (+78 -0) 📝 `tools/bvh_packing_check.py` (+26 -7) </details> ### 📄 Description Reopening my original upstream PR #7594 (refined per `@Envyre` and `@kapitche`'s reviews), cleanly rebased onto `main`: 1. **Harden `bvh4-chunk` continuation joining (`scan_window`)**: - Skips false-positive `ZHDR` bytes in padding only within a bounded 16-byte slop (`prev_end + 16`) after a failed `_inflate`, so a damaged continuation stops cleanly as `short_input` instead of skipping ahead to glue an unrelated later `raw` stream. - Stops continuation joining on any non-`raw` stream (`more_kind != "raw"`, including XML streams). - Defers recording `continuation` counts and `consumed` offsets until the joined stream actually reaches `declared_bytes`, so failed joins do not steal unrelated streams. 2. **Catch NaN/Inf in root bounds comparisons (`_root_equal`, union check)**: Rejects NaN anywhere in root bounds or child union (`min([0.0, nan])` silently returned `0.0`) and rejects infinite vs finite BOX32 bounds. ### Verification - `python3 -I tests/test_bvh_packing_check.py -v`: 33/33 pass (both new tests fail against `main`). - `python3 -I scripts/check_no_game_data.py tools/bvh_packing_check.py tests/test_bvh_packing_check.py`: clean. - `python3 -m compileall -q tools/bvh_packing_check.py tests/test_bvh_packing_check.py`: clean. Claimed in the coordination issue as: OLD-7594 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135123647) AI-assisted: yes (Gemini) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#915
No description provided.