[PR #2331] d3d12_title_image_census: guard null entries/resources and use stable_sort #2335

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2331
Author: @narekshaghoyandev
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: ubiq-title-image-census-guards


📝 Commits (1)

  • d11cbcc d3d12_title_image_census: guard null entries/resources and use stable_sort

📊 Changes

2 files changed (+76 additions, -2 deletions)

View changed files

📝 runtime/shims/d3d12_title_image_census.h (+4 -2)
➕ runtime/test/d3d12_title_image_census_test.cpp (+72 -0)

📄 Description

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://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194035099)
AI-assisted: yes (Gemini)


🔄 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/2331 **Author:** [@narekshaghoyandev](https://github.com/narekshaghoyandev) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `ubiq-title-image-census-guards` --- ### 📝 Commits (1) - [`d11cbcc`](https://github.com/ubiquitarianism/leonida/commit/d11cbcc1f552f2f4fb2a4c23f8964d33346d698b) d3d12_title_image_census: guard null entries/resources and use stable_sort ### 📊 Changes **2 files changed** (+76 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_title_image_census.h` (+4 -2) ➕ `runtime/test/d3d12_title_image_census_test.cpp` (+72 -0) </details> ### 📄 Description 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://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194035099) AI-assisted: yes (Gemini) --- <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#2335
No description provided.