mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:00:52 +01:00
[PR #2024] runtime: make RewrittenBlob COM refcount atomic in d3d12_xs_rootsig #2030
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#2030
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/2024
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-xs-rootsig-atomic-blob-refcount📝 Commits (1)
f1d796cruntime: make RewrittenBlob COM refcount atomic in d3d12_xs_rootsig📊 Changes
2 files changed (+84 additions, -3 deletions)
View changed files
📝
runtime/shims/d3d12_xs_rootsig.cpp(+4 -3)📝
runtime/test/root_sig_test.cpp(+80 -0)📄 Description
Coordination item:
RT-XS-ROOTSIG-ATOMIC-BLOB-REFCOUNT(claimed on #1608).Why
RewrittenBlobinruntime/shims/d3d12_xs_rootsig.cpp(returned byserialize_versioned_keeping_heap_flagsandserialize_legacy_keeping_heap_flagswhen retrying directly-indexed root-signature flags) implements the COMID3DBlobinterface with a plain non-atomicULONG refs_ = 1incremented/decremented via++refs_/--refs_. COM objects handed back to the title can haveAddRef/Release/QueryInterfacecalled concurrently from multiple worker threads (e.g. pipeline/root-signature build threads), which causes a data race, lost increments/decrements, and prematuredelete this/ use-after-free or leaks.Changes
runtime/shims/d3d12_xs_rootsig.cpp: changeRewrittenBlob::refs_tostd::atomic<ULONG> refs_{1}usingfetch_add(1, std::memory_order_relaxed) + 1inAddRef()andfetch_sub(1, std::memory_order_acq_rel) - 1inRelease().runtime/test/root_sig_test.cpp: addtest_rewritten_blob_concurrent_refcount()exercisingserialize_versioned_keeping_heap_flags()'s retry path, verifying restored RTS0 flags, and stressing 4 threads × 20,000 concurrentAddRef/Releasepairs on the returnedRewrittenBlob.Verification
d3d12.hCOM/struct stubs; Windows CI / fullroot_sig_testcovers the live hostd3d12.dllpaths).runtime/shims/d3d12_xs_rootsig.cpp+ concurrency test harness withclang++ -std=c++20 -Wall -Wextra -Werror:-O1 -g -fsanitize=address,undefined): 10/10 PASS.-O1 -g -fsanitize=thread): 10/10 PASS, 0 data races (negative control againstmain'sd3d12_xs_rootsig.cppreliably trippedWARNING: ThreadSanitizer: data raceinRewrittenBlob::AddRef).-O2): 10/10 PASS.python3 -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_rootsig.cpp runtime/test/root_sig_test.cpp: clean.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.