Repository navigation
d3d12: a geometry tile dropped while slot-133 shadows guard it reopens them too (RT-NULL-VTABLE-P4E683D6) - #2471
Conversation
…s them too (RT-NULL-VTABLE-P4E683D6) The geometry watch makes a title tile read-only to see the title's writes; a page of it can also be one a slot-133 shadow keeps read-only. A write fault and a kernel write already have the shadows reopen the tile, but release(), the last cell over it going away, opened the pages and only left a title_memory_map entry for the next refresh: a write-back in between still took them for unchanged and copied the shadow's older bytes over the title's write. release() now calls a reopener the layer installs, over the tile, with the watch's mutex released (the fault handler takes a shadow's lock and then this mutex); the layer points it at the shadows' reopen_range. Test: geometry_writes_test, on private pages, negative control included (5 checks fail with the call removed).
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and locally tested at 1de863bca (merged cleanly onto main ec91d695c).
Verification
- Environment: Windows 11, MSVC 19.44, NVIDIA GeForce RTX 5070 (driver 610.88, Vulkan 1.4.341;
VK_LAYER_KHRONOS_validationnot installed locally). ctest:geometry_writes,d3d12_existing_heap,d3d12_existing_heap_no_write_watch,d3d12_title_window_write_back, andd3d12_title_window_write_back_faultall passed (5/5).scripts/check_no_game_data.pyandgit diff --check: clean.
Review notes
- Lock ordering looks sound across all
geometry_writes::release()callers:release()restores protections and erases the cell unders.mutex, unlockss.mutex, and only then invokesreopen_shadow_ranges()(g_shadow_pages_lockshared -->ShadowPages::lock_exclusive -->geometry_writes::notify), matchingshadow_write_fault's order. BothShadowPages::reopen_all()andShadowPages::update_aliased()already releaseShadowPages::lock_before callingrelease_cells()/geometry_writes::release(), andGeometryViewsonly holds its own mutex. - Keeping
reopen(va, it->second)befores.cells.erase(it)avoids leaving a pagePAGE_READONLYwith no live cell to answer a concurrent write fault. There is still a narrow concurrent window betweenreopen()making the page writable andreopen_ranges()acquiringShadowPages::lock_where another thread'sShadowPages::write_back()(e.g., ifrelease()runs on the async geometry refresher thread) could observekProtectedbefore the reopen lands, though that is much tighter than leavingkProtectedstale until the next refresh. - No blocking issues found.
AI-assisted.
|
Reviewed at head Verification
Notes (non-blocking)
Approve. AI-assisted review + local MSVC verification. |
lixonik
left a comment
There was a problem hiding this comment.
Re-reviewed 1de863bca and verified on RTX 5070 with Khronos validation enabled.
Code audit:
runtime/src/title_geometry_watch.h,runtime/shims/d3d12_vulkan_device.cpp: invokingreopen_shadow_rangesoutsides.mutexwhenevergeometry_writes::release()makes guarded pages writable without a write fault cleanly preserves lock ordering (g_shadow_pages_lock-> geometry watch mutex) and prevents slot-133 write-backs from overwriting subsequent title writes with stale shadow bytes.
Verification (Windows 11, MSVC 19.44, Ninja Release, LEONIDA_VK_VALIDATION=1):
- Built
geometry_writes_testandd3d12_existing_heap_test. ctest -R '^(geometry_writes|d3d12_existing_heap|d3d12_existing_heap_no_write_watch)$': 3/3 passed (0 validation errors).python -I scripts/check_no_game_data.py: passed.
GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, VK_LAYER_KHRONOS_validation 1.4.363).
AI-assisted (Antigravity, Gemini).
|
#2471 | head 1de863b (merged cleanly with main 1bc055e) | |
d3d12: a geometry tile dropped while slot-133 shadows guard it reopens them too (RT-NULL-VTABLE-P4E683D6)
Claimed in the coordination issue as: RT-NULL-VTABLE-P4E683D6.
What and why
The geometry watch (
runtime/src/title_geometry_watch.h) makes a title tile read-only so it sees the title's writes to it. A 4 KiB page of that tile can also be one a slot-133 shadow (ShadowPagesinruntime/shims/d3d12_vulkan_device.cpp) keeps read-only: both guard the title's geometry, each queries and protects under its own lock.Two of the three ways a tile is opened again already tell the shadows, and the third did not:
shadow_write_faultasks the watch first, and when the watch reopened the whole 64 KiB tile (tile_reopened) every shadow over it callsreopen_range(commitba626820);open_shadow_pagesdoes the same for the range, rounded out to the tiles the watch reopened;release): it made the pages writable and only left atitle_memory_map::changedentry, whose effect reaches the shadows at their nextrefresh().Between that opening and the next refresh,
ShadowPages::write_backstill sees the page askProtected, itsheld()predicate is false, and it copies the shadow's older bytes over the title's write. That is the measured shape of+0x4e683d6: the title read an object at[arg+0x10], found its vtable word zero ([rcx] = 0, fault at address0x0,rax = 0) and called through it. The stop only happened in the run that hadLEONIDA_GEOMETRY_MB=2048, the only one where the geometry watch guarded thousands of 64 KiB tiles; the run without it went past that point.What
release()now calls a reopener the layer installs, over the tile whose pages it just made writable, with the watch's mutex released: the fault handler takes a shadow's lock and then the watch's mutex, so calling the shadows under it would invert the order and deadlock. The D3D12 layer points the reopener atreopen_shadow_ranges, the same shadow halfopen_shadow_pagesused. The journal entry stays, for shadows that cover a page of the tile but are not open at the time.Test
runtime/test/geometry_writes_test.cpp(ctest -R ^geometry_writes$), on a private allocation, no GPU and no game data:notify), which takes the watch's mutex: a release that called it with the mutex held deadlocks there (ctest reports the timeout);Negative control: with the reopener call removed, the test fails 5 checks (
calls == 1, the two range checks, the mutex check and the two-holder case).Which GPU
Measured on the card of the report: GeForce GTX 1050 Ti, NVIDIA 582.28, Windows 10 Pro 19045.
geometry_writes_testpasses there, andd3d12_existing_heap(the slot-133 shadow test) fails exactly as it does onmain—texture memory unavailable: 2048 bytes, alignment 1024, type bits 0x0 (vk format 9 256x8), the case #1894 fixes; with that head applied it passes 3/3 with this change. So nothing new fails here.AI-assisted (OpenCode, DeepSeek).