Repository navigation
runtime/shims: remove function-local static guards in winhttp_offline - #7198
emirhan-karaca wants to merge 1 commit into
Conversation
|
Independent native Windows 11 x64 / MSVC 19.44.35223 check of dbcaaa9 on main 8575d36. |
|
Tested dbcaaa9 merged onto main e0816d6 on an RTX 5090 (driver 621.24), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
|
Tested dbcaaa9 on NVIDIA GeForce RTX 5060 Ti, driver 621.24 (32.0.16.2124), Windows 11 Pro 26300, MSVC (VS 18 Build Tools) RelWithDebInfo, Vulkan headers via
Read the full diff before building. No game files. AI-assisted (Claude Code). |
|
Tested |
@ItsNotRexed pinging as requested for an EXE/runtime PR.
Claim: #7049 (comment) (item 2)
Context: RT-488 / #7074 (function-local dynamic
staticinit guard null-dereference on guest threads under Wine / static-CRT cross-builds and when the mapped executable owns TLS slot 0).Problem
runtime/shims/winhttp_offline.cppused five function-local dynamicstaticinitializers (live_mutex()::m,live()::s,log_refused()::logged,log_refused()::mutex, andcrack_url()::host) plus a function-localstd::once_flaginopen_session().When
libHttpClient.GDK.dllorXCurl.dllcalls WinHTTP fromgame_threadunder Wine, static-CRT clang-cl cross-builds, or with#4313(mapped retail EXE owning TLS slot 0), MSVC/clang-cl's_Init_thread_headerguard reads_Init_thread_epochfrom TLS slot 0 — the exact same bug class that caused the RT-488 /#7074null dereference inlibrary_loader.cpp.Changes
runtime/shims/winhttp_offline.cpp:live_mutex()/live()with constant-initializedSRWLOCK g_live_lock = SRWLOCK_INITand a lazy immortalstd::set<Handle*>* g_liveallocated underg_live_lock(acquire/close_handletreat!g_liveas invalid without allocating).log_refused()'slogged/mutexwith constant-initializedSRWLOCK g_log_lock = SRWLOCK_INITand lazy immortalstd::set<std::wstring>* g_logged.open_session()'sstatic std::once_flagwith constant-initializedstd::atomic<bool> g_banner_logged{false}.crack_url()'s function-local lambda static with constant-initializedINIT_ONCE g_crack_url_once = INIT_ONCE_STATIC_INIT(InitOnceExecuteOnce).#4209(which edits lines 253–385 ofwinhttp_offline.cppand lines 141–250 ofwinhttp_offline_test.cpp).runtime/test/winhttp_offline_test.cpp:WinHttpOpen,WinHttpConnect,WinHttpOpenRequest,WinHttpSendRequestrefused-server deduplication,WinHttpCrackUrl, andWinHttpCloseHandle.Verification
g++ 16.2.0(-std=c++20 -O2 -Wall -Wextra -Werroronwinhttp_offline.cppin both ANSI and-DUNICODE -D_UNICODEmodes and onwinhttp_offline_test.cpp: 0 warnings).nm -Candnm -uonwinhttp_offline.o):origin/main09b9ba886): 5 function-local guard variables (live_mutex()::m,live()::s,log_refused()::mutex,log_refused()::logged,crack_url()::host) plus undefined__cxa_guard_acquire/__cxa_guard_release/__cxa_guard_abort/__once_proxy/pthread_once.__cxa_guard_*, 0_tls_index, 0__once_proxy.exit=0 | 84 check(s), 0 failure(s)).exit=0 | 84 check(s), 0 failure(s)).CRLF=0on both files,git diff --checkexit 0.Disclosures
g++ 16.2.0(linking untouchedregistry.cppwith a scratch_AddressOfReturnAddressintrinsic stub); no local MSVCcl.exeor CMake. Full MSVC/W4 /permissive- /utf-8+ctestruns in CI.