d3d12_title_image_census: guard null entries/resources and use stable_sort #2331

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

@⁠narekshaghoyandev on GitHub · 2026-11-26 13:57 UTC · original
narekshaghoyandev:ubiq-title-image-census-guards → main · +76 −2 · 2 files · 1 commits · open

Fixes null-pointer dereferences and non-deterministic tie-breaking in rt::d3d12::log_title_image_uses() (runtime/shims/d3d12_title_image_census.h):

  • Skip null registry entries (!t) in both passes over textures before dereferencing t->owned / t->cpu.
  • Guard !t->resource before dereferencing t->resource->desc() for placed entries.
  • Use std::stable_sort instead of std::sort when ranking classes (copied from an ordered std::map<Shape, AllocationClass>) so equal-sized shapes break ties deterministically.
  • Added standalone unit test runtime/test/d3d12_title_image_census_test.cpp.

Verification

  • g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic runtime/test/d3d12_title_image_census_test.cpp passed
  • g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic runtime/test/d3d12_title_image_census_test.cpp passed
  • Negative control: new test failed with UBSan null-member-access + ASan SEGV against unmodified ubiq/main
  • python3 -I scripts/check_no_game_data.py runtime/shims/d3d12_title_image_census.h runtime/test/d3d12_title_image_census_test.cpp clean

Claimed in the coordination issue as: RT-TITLE-IMAGE-CENSUS-NULL-GUARDS (#1608)
AI-assisted: yes (Gemini)

**@⁠narekshaghoyandev** on GitHub · 2026-11-26 13:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2331) `narekshaghoyandev:ubiq-title-image-census-guards` → `main` · +76 −2 · 2 files · 1 commits · open Fixes null-pointer dereferences and non-deterministic tie-breaking in `rt::d3d12::log_title_image_uses()` (`runtime/shims/d3d12_title_image_census.h`): - Skip null registry entries (`!t`) in both passes over `textures` before dereferencing `t->owned` / `t->cpu`. - Guard `!t->resource` before dereferencing `t->resource->desc()` for placed entries. - Use `std::stable_sort` instead of `std::sort` when ranking `classes` (copied from an ordered `std::map<Shape, AllocationClass>`) so equal-sized shapes break ties deterministically. - Added standalone unit test `runtime/test/d3d12_title_image_census_test.cpp`. ### Verification - `g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic runtime/test/d3d12_title_image_census_test.cpp` passed - `g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic runtime/test/d3d12_title_image_census_test.cpp` passed - Negative control: new test failed with UBSan null-member-access + ASan SEGV against unmodified `ubiq/main` - `python3 -I scripts/check_no_game_data.py runtime/shims/d3d12_title_image_census.h runtime/test/d3d12_title_image_census_test.cpp` clean Claimed in the coordination issue as: RT-TITLE-IMAGE-CENSUS-NULL-GUARDS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) AI-assisted: yes (Gemini)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:01:32 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 15:40 UTC · original · reviewed

Ran d3d12_title_image_census_test.cpp directly with GCC 11 and UBSan on Ubuntu/WSL. The synthetic census passed without sanitizer findings. Could the new source also be registered with CTest? It currently has no build/test entry.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 15:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2331#pullrequestreview-6076920688) · **reviewed** Ran `d3d12_title_image_census_test.cpp` directly with GCC 11 and UBSan on Ubuntu/WSL. The synthetic census passed without sanitizer findings. Could the new source also be registered with CTest? It currently has no build/test entry. AI-assisted.
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/2331/head:github-bot/gh-2331'
git switch 'github-bot/gh-2331'

Merge

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