mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #1725] tests: heap-lock touchers allocate from the process heap, not the debug CRT (RT-XMEM-HEAP-LOCK-DEADLOCK) #1740
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#1740
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/1725
Author: @Tyrannys
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:claude/xmem-heap-deadlock📝 Commits (2)
596fe1ftests: xmem heap-lock toucher allocates from the process heap, not the debug CRT7c0215dtests: d3d12_existing_heap heap-lock touchers allocate from the process heap📊 Changes
2 files changed (+14 additions, -8 deletions)
View changed files
📝
runtime/test/d3d12_existing_heap_test.cpp(+6 -4)📝
runtime/test/xmem_test.cpp(+8 -4)📄 Description
Claimed in the coordination issue as: RT-XMEM-HEAP-LOCK-DEADLOCK (ubiquitarianism/leonida#1608)
Item: RT-XMEM-HEAP-LOCK-DEADLOCK (kotekompotek's finding in #1608:
xmem_testhangs in the "xmem heap-lock faults" section in a Debug build on Windows, all three variants).Cause (measured, not xmem)
At the hang I walked every test thread's stack from the watchdog (temporary instrumentation, not committed):
HeapLock(GetProcessHeap())and is in the debug CRT's_aligned_free→_free_dbg→EnterCriticalSection, waiting for the CRT's own heap lock;__CxxFrameHandler3→_calloc_dbg, which holds that CRT lock, →RtlAllocateHeap, waiting for the process heap.xmem's
g_fault_lockisn't in the cycle, and the heap gate can't stop it because the CRT's internalcallocdoesn't go throughoperator new. A release CRT's_aligned_mallocis justHeapAllocand takes no lock of its own, which is why RelWithDebInfo passes, and why the title'sXMemAlloc(its own release CRT) can't hit this. So the bug is in the test's emulation, not in the fault handler.d3d12_existing_heap_test'scheck_heap_lock_faultshas the same pattern and hangs the same way in Debug (all three variants: "vulkan slot-133 heap-lock faults: no progress for 30 s"). Its allocator threads take the CRT lock and then the heap lock directly.Fix
The touchers in both tests
HeapAlloc/HeapFreeon the process heap while they hold its lock, instead of the test binary's_aligned_malloc/_aligned_free. They still write heap block headers under the heap's lock while faulting, which is what the section tests. Nothing is skipped and no check changes. The comments say why.Tested
Windows 11 Pro (26300), MSVC 14.52, RTX 4070 SUPER, no game files:
xmem_test xmemexit 3 on every run (watchdog). After: no hang in 105 runs of the threexmem*variants. Debug ctestxmem*andd3d12_existing_heap*: 6/6 pass.ctest400/402. The two failures werexmem_write_watch("the reader of the views' last pages never faults or misreads") and anapi_ref_state30 s timeout. Both then passed--repeat until-fail:3together with the other heap-lock tests (7/7 ×3).vk_presenter_sync_test.cpp(C1128, needs/bigobj), and the Debugrun_tiny_*andreplay_*tests fail on this machine. None of them link the two test files changed here.python -I scripts/check_no_game_data.pyon both files: clean.djrolfes' Wine 11.22 read-only XMem findings in #1608 have a different cause (VirtualQuery state under Wine). This PR doesn't touch them, and the Wine skip of the heap-lock section stays as it is.
AI-assisted (Claude Code).
GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 Pro 26300
AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.