Repository navigation
runtime/shims: remove function-local static guards in registry and classify XCRDAPI!DStorageGetFactory - #7175
Conversation
…assify XCRDAPI!DStorageGetFactory
|
Independent native Windows/MSVC 19.44, SDK 10.0.26100, RelWithDebInfo verification at eccdada: configured an isolated CPU-only CMake build, built registry_init_and_classify_test, ran it: 25 checks, 0 failed. Concurrent registry/thunk/bundled-loader stress and XCRDAPI HRESULT classification checks passed. No C++ source warning observed; MSBuild reports MSB8029 because the isolated build is under TEMP. Vulkan headers unavailable; this is CPU registry coverage. No game files. AI-assisted (Codex). |
|
Tested eccdada on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass
AI-assisted (Claude Code). |
|
Tested under Wine 11.22 (CachyOS), clang-cl 23.1.5 + xwin build (which shows the fault), RTX 3060 Laptop / NVIDIA 620.73.04, retail 1.0.2.1 exe (own copy), no-network sandbox. Outcomes only.
So on this build the fault needs #4313 (the TLS block at index 0), not only the registry change. AI-assisted (Claude Code). |
@ItsNotRexed pinging as requested for an EXE/runtime PR.
Claim: #7049 (comment) (item 1)
Context: RT-488 / #7074 (function-local static init guard null-dereference on guest threads under Wine / static-CRT cross-builds and when the mapped executable owns TLS slot 0) and #6715 (retail executable dry-run reported
unimplemented by return policy: hresult=0 other=30despite importingXCRDAPI.dll!DStorageGetFactory).Problem
runtime/shims/registry.cpp(RT-488 class):table(),bundled_loader_mutex(),bundled_loaders(), andmake_unimplemented_thunk()'ss_thunksall used function-local dynamicstaticinitializers (static auto* m = new .../static std::map<...>), the exact same pattern that caused the RT-488 /#7074null dereference inlibrary_loader.cppwhen called from a guest thread under Wine or static-CRT cross-builds /#4313(where MSVC/clang-cl's_Init_thread_headerguard reads_Init_thread_epochfrom TLS slot 0).XCRDAPI.dllinclassify()(#6715):classify()already classifiesDStorageGetFactoryasReturnClass::HResultfordstorage.dllanddstorage_xs.dll, butgame_scarlett_master.exeimportsDStorageGetFactoryfromXCRDAPI.dll. UnderLEONIDA_UNIMPLEMENTED=fail(when noXCRDAPI.dllshim is registered), it returned0(S_OK) with a null out-pointer instead ofE_NOTIMPL.Changes
runtime/shims/registry.cpp:table()'s function-localstatic std::mapwith a constant-initializedINIT_ONCE(InitOnceExecuteOnce) immortal map pointer — preserves cross-TU static-init safety forSHIM_TABLEand teardown immortality with zero function-local static init guard.bundled_loader_mutex()andbundled_loaders()with a constant-initializedSRWLOCK(SRWLOCK_INIT) and lazy immortalstd::vector*allocated under the lock (fast empty return when no bundled loader is registered).make_unimplemented_thunk()'ss_thunksto a namespace-scope pointer lazily allocated under the already-heldg_pool_mutex.dll == "xcrdapi.dll"alongsidedstorage.dll/dstorage_xs.dllforDStorageGetFactoryinclassify().registry.cpp:startup_trace.h's inlinemutex()guard is left untouched to avoid overlap with openstartup_trace.hPRs.)runtime/test/registry_init_and_classify_test.cpp(new) &runtime/CMakeLists.txt:registry_init_and_classify_test(ctestnameregistry_init_and_classify) coveringSHIM_TABLEresolution,owns_dll,XCRDAPI.dll!DStorageGetFactoryclassification &E_NOTIMPLthunk execution underFailpolicy, bundled-loader null/register/dispatch/remove lifecycle, and 4-thread concurrent stress.Verification
g++ 16.2.0(-std=c++20 -O2 -Wall -Wextra -Werroronregistry.cppin both ANSI and-DUNICODE -D_UNICODEmodes, plus-Wconversion -Wsign-conversion -Werroronregistry_init_and_classify_test.cpp: 0 warnings).nm -C):origin/main09b9ba886registry.o): 4 guard variables inregistry.cpp(table()::t,bundled_loader_mutex()::m,bundled_loaders()::v,make_unimplemented_thunk::s_thunks) plus headerrt::startup_trace::detail::mutex()::m.registry.o): 0 guard variables inregistry.cpp(only the untouchedstartup_trace.hheader symbol remains).registry_init_and_classify_test.cpplinked against unmodifiedorigin/mainregistry.cpp):exit=1 | 25 checks, 3 failed(XCRDAPI.dll!DStorageGetFactoryclassified asOtherand returned0instead ofE_NOTIMPL).exit=0 | 25 checks, 0 failed).exit=0 | 25 checks, 0 failed).winhttp_offline_testlinked with patchedregistry.o: PASS (83 check(s), 0 failure(s)).CRLF=0on all 3 files,git diff --checkexit 0.Disclosures
g++ 16.2.0(with a scratch_AddressOfReturnAddressintrinsic stub forregistry.cpp:160, since MinGW lacks the MSVC intrinsic) and has no local MSVCcl.exeor CMake; full MSVC/W4 /permissive- /utf-8+ctestruns in CI.