d3d12_title_image_census: guard null entries/resources and use stable_sort #2331
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2331"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-26T13:57:14Z.
Fixes null-pointer dereferences and non-deterministic tie-breaking in
rt::d3d12::log_title_image_uses()(runtime/shims/d3d12_title_image_census.h):!t) in both passes overtexturesbefore dereferencingt->owned/t->cpu.!t->resourcebefore dereferencingt->resource->desc()for placed entries.std::stable_sortinstead ofstd::sortwhen rankingclasses(copied from an orderedstd::map<Shape, AllocationClass>) so equal-sized shapes break ties deterministically.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.cpppassedg++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic runtime/test/d3d12_title_image_census_test.cpppassedubiq/mainpython3 -I scripts/check_no_game_data.py runtime/shims/d3d12_title_image_census.h runtime/test/d3d12_title_image_census_test.cppcleanClaimed in the coordination issue as: RT-TITLE-IMAGE-CENSUS-NULL-GUARDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194035099)
AI-assisted: yes (Gemini)
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:40:36Z.
Review: COMMENTED
Ran
d3d12_title_image_census_test.cppdirectly 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.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:02:34Z.
VERIFY-2331-D3D12— verified headd11cbcc1f5merged cleanly withmain030d2039eon Windows 11 Pro (build 26200), MSVC19.44(x64,/std:c++20 /W4 /WX /permissive- /utf-8 /EHsc), synthetic registry entries only.Red (
main030d2039e) -> Green (030d2039e+d11cbcc1f5)main:runtime/test/d3d12_title_image_census_test.cppagainstmain'sruntime/shims/d3d12_title_image_census.h-> crashed with0xC0000005(STATUS_ACCESS_VIOLATION) dereferencingt->ownedon the null registry entry (textures.emplace(2, nullptr)).cl.exe /nologo /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc runtime/test/d3d12_title_image_census_test.cpp-> 0 warnings, exit0(d3d12_title_image_census_test: ok, reporting1 slot-70 images sharing slot-133 base 2.0 MiBand1 retired awaiting release 1.0 MiBwithout dereferencing null entries or nullt->resource).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:02:09Z.
Verified by OreoFR
c1ecf04ed+ PR headd11cbcc1f; green run in a merge package of 16 PRs, no new ctest failure vs mainstandalone build of d3d12_title_image_census_test.exe (the test is not registered in CMake)AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T22:49:49Z.
Tested
d11cbcc1fmerged (no commit) withmainaa918e5d9, MSVC 19.52 (Visual Studio 18), Windows 11 10.0.26300.Blocker:
runtime/test/d3d12_title_image_census_test.cppis new but is not registered inruntime/CMakeLists.txt, so neither CI norctestever builds or runs it.ctest -Non the merge lists no such test, andtests/test_ctest_registration.pystill passes, so nothing catches this. Registering it the way the other header-only tests are would fix that:Hand-compiled (
cl /std:c++20 /EHsc /O2):runtime/shims/d3d12_title_image_census.hback tomain: crash, exit0xC0000005.I did not run the ctest tests relinked by the header change: test runs on this machine are paused for memory.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:27:52Z.
Review: COMMENTED
Static audit of
d11cbcc1fonly, with no builds or GPU runs. Both passes inruntime/shims/d3d12_title_image_census.hnow guard null registry pointers, and the placed-resource guard precedes every resource dereference in the helper. The comparator uses>on unsigned byte totals, which gives a strict weak ordering even if a sum wraps.std::stable_sortpreservesstd::mapshape order for equal keys. The fixture uses standard C++20 facilities, and the PR discussion reports standalone GCC and MSVC runs.runtime/test/d3d12_title_image_census_test.cpp:45— Please add the executable and itsadd_testentry in the portable section ofruntime/CMakeLists.txt. The runtime CI jobs currently omit this regression from their CMake build and CTest run.runtime/shims/d3d12_title_image_census.h:36— Please move the placed-resource guard above the deferred counters andplaced_addresses.insert. A placement cleared bytitle_texture_goneinruntime/shims/d3d12_vulkan_device.cppretains its cached values until the drain. Counting it in that window inflates deferred totals if its cached value is nonzero and can report a slot-70 alias against a dead slot-133 placement.runtime/test/d3d12_title_image_census_test.cpp:69— The fixture produces one ranked class and checks that the helper returns. Please add distinct shapes with equal totals and assert their emitted order to cover the tie-breaking change.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:26:12Z.
Merged. Tested by OreoFR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) on this head: d3d12_title_image_census_test red on main (crash 0xC0000005), green with the PR. Note: the test is not registered in CMake. AI-assisted: yes.