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

Open
github-bot wants to merge 1 commit from github-bot/gh-879 into main AGit
Owner

@⁠narekshaghoyandev on GitHub · 2026-11-24 14:54 UTC · original
narekshaghoyandev:ubiq-bvh-packing-check-continuations-and-nan → main · +104 −7 · 2 files · 1 commits · open

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 (#14)
AI-assisted: yes (Gemini)

**@⁠narekshaghoyandev** on GitHub · 2026-11-24 14:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/879) `narekshaghoyandev:ubiq-bvh-packing-check-continuations-and-nan` → `main` · +104 −7 · 2 files · 1 commits · open 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://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) AI-assisted: yes (Gemini)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:26:05 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-24 19:34 UTC · original

Reviewed 4b32bdc: ran tests/test_bvh_packing_check.py (33 OK here, 31 on main) plus a probe script on both main and this head (NaN/Inf root unions, the _root_equal matrix, eight join inputs, a 2-worker/64-byte-window run, a 25-archive fuzz; no crashes on either side). Reproduced on main, all fixed here: wide (1.0, inf) / (inf, -inf) and narrow nan/nan equalities returned True; a NaN root-union override was order-dependent and could count as equal with no failure; a false 78 9c in chunk padding broke a good join and misreported the continuation as raw; a following bvh4/xml stream could be glued into the join and vanish from the report; failed joins recorded bogus continuation counts. Legal BOX16 +/-inf unions still pass, so no regressions found. gh is disabled for me, so I could not check the coordination-issue claim. AI-assisted review.

**@⁠PierreEbele** on GitHub · 2026-11-24 19:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/879#issuecomment-7142295887) Reviewed 4b32bdc: ran tests/test_bvh_packing_check.py (33 OK here, 31 on main) plus a probe script on both main and this head (NaN/Inf root unions, the `_root_equal` matrix, eight join inputs, a 2-worker/64-byte-window run, a 25-archive fuzz; no crashes on either side). Reproduced on main, all fixed here: wide `(1.0, inf)` / `(inf, -inf)` and narrow nan/nan equalities returned True; a NaN root-union override was order-dependent and could count as equal with no failure; a false `78 9c` in chunk padding broke a good join and misreported the continuation as raw; a following bvh4/xml stream could be glued into the join and vanish from the report; failed joins recorded bogus continuation counts. Legal BOX16 +/-inf unions still pass, so no regressions found. gh is disabled for me, so I could not check the coordination-issue claim. AI-assisted review.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/879/head:github-bot/gh-879'
git switch 'github-bot/gh-879'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-879'
git switch 'github-bot/gh-879'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-879'
git switch 'github-bot/gh-879'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-879'
git switch 'main'
git merge --squash 'github-bot/gh-879'
git switch 'main'
git merge --ff-only 'github-bot/gh-879'
git switch 'main'
git merge 'github-bot/gh-879'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.