descriptor_range_changes: merge adjacent inclusive ranges, skip inverted ranges, and add unit test #2288

Closed
narekshaghoyandev wants to merge 1 commit from upstream-pr/2288 into main
narekshaghoyandev commented 2026-11-26 12:48:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-26T12:48:24Z.


Summary

  • Coalesce adjacent inclusive ranges ([0, 9] + [10, 19] -> [0, 19]) in DescriptorRanges::merge() (runtime/src/descriptor_range_changes.h), guarding against UINT64_MAX + 1 overflow.
  • Skip inverted ranges (first > last) in DescriptorRanges::merge() so ranges preserves the monotonic last invariant required by std::lower_bound in overlaps().
  • Add standalone C++20 unit test runtime/test/descriptor_range_changes_test.cpp (no GPU, no game data) and register it in runtime/CMakeLists.txt.

Verification

  • g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -O1 -g runtime/test/descriptor_range_changes_test.cpp — descriptor_range_changes_test: OK.
  • g++ -std=c++20 -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined -O1 -g runtime/test/descriptor_range_changes_test.cpp — descriptor_range_changes_test: OK.
  • g++ -std=c++20 -Wall -Wextra -Werror -pedantic -O1 -g runtime/test/title_va_alias_test.cpp — pass.
  • Negative control against main: 7 checks fail before the patch and all pass after.
  • python3 -I scripts/check_no_game_data.py runtime/src/descriptor_range_changes.h runtime/test/descriptor_range_changes_test.cpp runtime/CMakeLists.txt — clean.

Claimed in the coordination issue as: RT-DESC-RANGE-MERGE-ADJACENT (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192440165)
AI-assisted: yes (Gemini)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5510305067 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2288). Originally posted by [narekshaghoyandev](https://github.com/narekshaghoyandev) on 2026-11-26T12:48:24Z. --- ## Summary - Coalesce adjacent inclusive ranges (`[0, 9]` + `[10, 19]` -> `[0, 19]`) in `DescriptorRanges::merge()` (`runtime/src/descriptor_range_changes.h`), guarding against `UINT64_MAX + 1` overflow. - Skip inverted ranges (`first > last`) in `DescriptorRanges::merge()` so `ranges` preserves the monotonic `last` invariant required by `std::lower_bound` in `overlaps()`. - Add standalone C++20 unit test `runtime/test/descriptor_range_changes_test.cpp` (no GPU, no game data) and register it in `runtime/CMakeLists.txt`. ## Verification - `g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -O1 -g runtime/test/descriptor_range_changes_test.cpp` — `descriptor_range_changes_test: OK`. - `g++ -std=c++20 -Wall -Wextra -Werror -pedantic -fsanitize=address,undefined -O1 -g runtime/test/descriptor_range_changes_test.cpp` — `descriptor_range_changes_test: OK`. - `g++ -std=c++20 -Wall -Wextra -Werror -pedantic -O1 -g runtime/test/title_va_alias_test.cpp` — pass. - Negative control against `main`: 7 checks fail before the patch and all pass after. - `python3 -I scripts/check_no_game_data.py runtime/src/descriptor_range_changes.h runtime/test/descriptor_range_changes_test.cpp runtime/CMakeLists.txt` — clean. Claimed in the coordination issue as: RT-DESC-RANGE-MERGE-ADJACENT (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192440165) AI-assisted: yes (Gemini)
kawaii-shakal commented 2026-11-26 16:31:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-26T16:31:29Z.

Review: APPROVED


Reviewed by Claude Code (AI-assisted) on my behalf. Approving.

  • The merge condition last == UINT64_MAX || r.first <= last + 1 joins adjacent inclusive ranges without
    overflowing at the top of the address space. Skipping first > last is harmless: record() never makes one.
  • overlaps() answers the same as before for every range, because merging only changes how the ranges are split.
  • Checked: descriptor_range_changes_test passes with -fsanitize=address,undefined (g++ 13, Linux). Built against
    main's header, it fails (lines 29-30, adjacent ranges not merged), so the test covers the change.

Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6077592927 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2288#pullrequestreview-6077592927). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-26T16:31:29Z. **Review:** APPROVED --- Reviewed by Claude Code (AI-assisted) on my behalf. Approving. - The merge condition `last == UINT64_MAX || r.first <= last + 1` joins adjacent inclusive ranges without overflowing at the top of the address space. Skipping `first > last` is harmless: `record()` never makes one. - `overlaps()` answers the same as before for every range, because merging only changes how the ranges are split. - Checked: `descriptor_range_changes_test` passes with `-fsanitize=address,undefined` (g++ 13, Linux). Built against main's header, it fails (lines 29-30, adjacent ranges not merged), so the test covers the change. --- _Generated by [Claude Code](https://claude.ai/code)_
MoonEyes commented 2026-11-28 02:55:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:55:19Z.


Hi @narekshaghoyandev, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/src/descriptor_range_changes.h), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232679515 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2288#issuecomment-7232679515). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:55:19Z. --- Hi @narekshaghoyandev, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/src/descriptor_range_changes.h`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-11-29 12:54:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T12:54:32Z.


Closing: runtime/src/descriptor_range_changes.h is no longer on main and DescriptorRanges appears nowhere, so this no longer applies. Reopen with a pointer if the code moved somewhere I missed.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256149542 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2288#issuecomment-7256149542). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T12:54:32Z. --- Closing: runtime/src/descriptor_range_changes.h is no longer on main and DescriptorRanges appears nowhere, so this no longer applies. Reopen with a pointer if the code moved somewhere I missed.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2288
No description provided.