Repository navigation
Conversation
…lts inside memcpy copy_guarded, hash_guarded and the other __try readers of the title's memory only caught a page fault under MSVC. clang-cl lowers memcpy to an intrinsic it treats as unable to throw, so without asynchronous exceptions the __except never runs: a shadow refresh that read a page xmem had just unmapped killed the process (ucrtbase memcpy, region MEM_RESERVE). Reproduced with a 20-line program under Wine 11.21: /EHsc dies, /EHa returns false from the guard. Only dstorage.cpp and thread_stacks.cpp had /EHa; the whole target needs it.
copy_guarded and hash_guarded are in d3d12_vulkan_device.cpp, which the static library gta6rt_d3d12_com compiles, not gta6rt: the first commit's /EHa never reached them (its build line still had /EHsc only), and a story-load boot died in the same copy.
… volatile pointer instead of relying on /EHa /EHa for gta6rt never reached these: they are compiled in gta6rt_d3d12_com. And /EHa on that library, or on every source, does not link with clang 20: it leaves std::variant's trivial destructor undefined (155 targets failed). So the /EHa lines go, and the fix moves to the two functions: their bodies are noinline functions called through a volatile pointer inside the __try. clang-cl then sees a call it cannot prove nothrow, and covers it; a fault in the inlined memcpy or loads of the old bodies was not. Checked with a small program under Wine 11.21 built with /EHsc: a fault from a MEM_RESERVE page is caught through both the memcpy and the MOVNTDQA path. Every target of runtime/ builds.
Contributor
Author
|
Updated: the /EHa approach in the first push did not reach |
Contributor
Author
|
Closing: #1723 (merged as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: RT-CLANG-EHA — #1608 (comment)
What and why
copy_guardedandhash_guarded(shims/d3d12_vulkan_device.cpp) read the title's memory inside__try/__except, so that a page the title unmaps between the check and the read comes back asfalseinstead of killing the process. That holds under MSVC. Under clang-cl with/EHscit does not: clang lowersmemcpyto an intrinsic it treats as unable to throw, and loads inlined into the__tryblock (the hash, theMOVNTDQApath) are not covered either, so the__exceptnever runs.Seen on a clang-cl/xwin build under Wine 11.21 (Fedora 44, RTX 2070 SUPER), twice during the story load: a slot-133 shadow refresh copied a page xmem had just unmapped and the process died. Startup trace exception record: read of
0x7fe6bac60000inucrtbase.dll+0x171a6(memcpy), regionMEM_RESERVE/MEM_PRIVATE; with a linker map, the stack iscopy_guarded<ShadowPages::refresh< the device's submission callback <VulkanQueue::execute_now<CommandQueue::ExecuteCommandLists.Change
The bodies become
noinlinefunctions (copy_unguarded,hash_unguarded) that the guards call through avolatilefunction pointer inside the__try. clang-cl then sees a call it cannot provenothrowand covers it. No build flag changes.The first version of this PR added
/EHainstead. That did not work:/EHaongta6rtnever reached these functions, whichgta6rt_d3d12_comcompiles, and/EHaon that library or on every source does not link with clang 20 (std::variant's trivial destructor is referenced but never emitted: 155 targets failed). Those commits are undone in this branch; the diff againstmainis onlyd3d12_vulkan_device.cpp.Tested
/EHsc, under Wine 11.21: a fault from aMEM_RESERVEpage is caught through the pointer call, both viamemcpyand via aMOVNTDQAloop, and a copy from committed memory still succeeds. The same function withmemcpydirectly in the__trydies at the sameucrtbase.dlladdress as the game run.runtime/cross-builds (ninja -k 0, 0 failed) onmain3de22a190.Other
__tryusers (file_system.cpp,pe_loader.cpp,title_page_watch.h,startup_trace.h) may have the same limit under clang-cl; I have not changed or tested them here.AI-assisted: yes (Claude Code).