[PR #331] meshlet_page: fix u16 running-sum wraparound, non-finite crashes, and 0-meshlet groups #383

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/10066


📝 Commits (1)

  • bcc3684 meshlet_page: fix u16 running-sum wraparound, non-finite crashes, and 0-meshlet groups

📊 Changes

2 files changed (+141 additions, -22 deletions)

View changed files

📝 tests/test_meshlet_page.py (+94 -0)
📝 tools/meshlet_page.py (+47 -22)

📄 Description

Carried over from old PR 10066 by ShotTechOp in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10066, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
ShotTechOp: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Summary

Clean rebase onto ProjectLeonida/Leonida main (de4c373) of formerly approved PR #8313 (closed in the bulk PR cleanup sweep):

  1. Unbounded running sums past 65,535 refs/triangles:
    • Replaces truncated 16-bit w1 offsets with accumulated running vbase/tbase sums in group_triangles(), cone_agreement(), centre_agreement(), and centre_distance(), preventing wraparound corruption on large groups.
  2. Non-finite (NaN/±inf) position, bias, and overflowing-normal guards:
    • Guards round() and distance/normal checks with math.isfinite in centre_agreement(), centre_distance(), and cone_agreement() so malformed or extreme inputs skip gracefully instead of raising ValueError/OverflowError or letting trailing NaNs slip past.
  3. Reject 0-meshlet groups in parse_group():
    • Raises PageError on empty groups (0x80000000, 0, 0) instead of accepting them.

Coordination & Prior Verification

Testing

Environment: Windows 11 x64, Python 3.12.10, CPU-only (rebased on de4c373).

  • python -I tests/test_meshlet_page.py -> 70/70 OK
  • python -m compileall -q tools/meshlet_page.py tests/test_meshlet_page.py -> exit 0
  • python -I scripts/check_no_game_data.py tools/meshlet_page.py tests/test_meshlet_page.py -> exit 0
  • git diff --check -> clean

🔄 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/331 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/10066` --- ### 📝 Commits (1) - [`bcc3684`](https://github.com/ubiquitarianism/leonida/commit/bcc36841ee10720cf9e25dd7aa35b677b6b663e5) meshlet_page: fix u16 running-sum wraparound, non-finite crashes, and 0-meshlet groups ### 📊 Changes **2 files changed** (+141 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_meshlet_page.py` (+94 -0) 📝 `tools/meshlet_page.py` (+47 -22) </details> ### 📄 Description > Carried over from **old PR 10066** by `ShotTechOp` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10066`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `ShotTechOp`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): ## Summary Clean rebase onto `ProjectLeonida/Leonida` `main` (`de4c373`) of formerly approved PR `#8313` (closed in the bulk PR cleanup sweep): 1. **Unbounded running sums past 65,535 refs/triangles**: - Replaces truncated 16-bit `w1` offsets with accumulated running `vbase`/`tbase` sums in `group_triangles()`, `cone_agreement()`, `centre_agreement()`, and `centre_distance()`, preventing wraparound corruption on large groups. 2. **Non-finite (`NaN`/`±inf`) position, bias, and overflowing-normal guards**: - Guards `round()` and distance/normal checks with `math.isfinite` in `centre_agreement()`, `centre_distance()`, and `cone_agreement()` so malformed or extreme inputs skip gracefully instead of raising `ValueError`/`OverflowError` or letting trailing `NaN`s slip past. 3. **Reject 0-meshlet groups in `parse_group()`**: - Raises `PageError` on empty groups (`0x80000000, 0, 0`) instead of accepting them. ## Coordination & Prior Verification - Claimed in `#9677`: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7117121412 - Supersedes closed `#8313` (previously **APPROVED** by `@leoleahy` and independently verified by `@ne1i`, `@garuspl`, `@sergiocr06`, and `@Atomic258`). - No game files used; synthetic tests only. - AI-assisted: yes (Antigravity). ## Testing Environment: Windows 11 x64, Python 3.12.10, CPU-only (rebased on `de4c373`). - `python -I tests/test_meshlet_page.py` -> 70/70 OK - `python -m compileall -q tools/meshlet_page.py tests/test_meshlet_page.py` -> exit 0 - `python -I scripts/check_no_game_data.py tools/meshlet_page.py tests/test_meshlet_page.py` -> exit 0 - `git diff --check` -> clean --- <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#383
No description provided.