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

Closed
leonida/mandy
narekshaghoyandev wants to merge 0 commits from ubiq-desc-range-merge-adjacent into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

narekshaghoyandev commented 2026-11-26 12:48:24 +00:00

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)

## 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 approved these changes 2026-11-26 16:31:29 +00:00
kawaii-shakal left a comment

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

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

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).

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

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.

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.
Sign in to join this conversation.
No description provided.