mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:30:52 +01:00
[PR #2048] runtime: guard null out/backing and skip expired entries in PlacedDepthTextures #2054
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2054
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2048
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:rt/placed-depth-null-out-and-expired-race📝 Commits (1)
f5ad49eruntime: guard null out/backing and skip expired entries in PlacedDepthTextures📊 Changes
2 files changed (+22 additions, -4 deletions)
View changed files
📝
runtime/shims/d3d12_xs_placed_depth.h(+17 -4)📝
runtime/test/d3d12_placed_depth_test.h(+5 -0)📄 Description
Claim ID:
RT-PLACED-DEPTH-NULL-OUT-AND-EXPIRED-RACESummary
Fixes four edge-case correctness and concurrency issues in
rt::d3d12_xs::PlacedDepthTextures::create()(runtime/shims/d3d12_xs_placed_depth.h):outand clear*outup front: Rejectout == nullptrwithE_POINTERbefore acquiringmutex_or invokingcreate_backing(avoiding a wasted GPU depth/stencil texture allocation and deadranges_entry), and clear*out = nullptrimmediately so every failure path (E_INVALIDARG,E_NOTIMPL, backing creation failure,E_OUTOFMEMORY) leaves*outnull per COM rules.S_OK: Ifcreate_backing(&resource)returnsS_OKwithresource == nullptr, returnE_FAILinstead of constructing aPlacedDepthTexturewith a nullbackingpointer and custom deleter[](ID3D12Resource* r) { r->Release(); }(which also now null-checksr).it->second.backing.lock()at the start of each iteration overranges_and erase/skip any entry that expired concurrently betweenstd::erase_ifand the loop, preventing spuriousE_NOTIMPLrejections against an already-released placement and reusing the already-lockedstd::shared_ptrdirectly.*outfailure-clearing assertion inruntime/test/d3d12_placed_depth_test.h.Verification
d3d12_depth_stencil_uavpending)PlacedDepthTextures::create):clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werror: PASS (failures=0)clang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werror(4 threads x 2,000 concurrent create/release alternating incompatible shapes at the same address): PASS (failures=0)clang++ -std=c++20 -O2 -Wall -Wextra -Werror: PASS (failures=0)main: failed 3 assertions (invokedcreate_backingonout == nullptr, left*outdirty onE_INVALIDARG, and acceptedS_OKwith nullresource, exit1).python3 -I scripts/check_no_game_data.pyclean;python3 -I tests/test_text_write_line_endings.py(3/3 OK).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.