在 2025-01-05 01:02, Pali Rohár 写道:
Hello,Do you know that is the purpose of __native_startup_state and __native_startup_lock variables used in __tmainCRTStartup() static function which is called only from the EXE application entry point? I tried to find some documentation, but there is nothing neither on Microsoft webpage and neither in gcc or mingw projects. It looks like that __native_startup_lock is some synchronization which prevents nested execution of __tmainCRTStartup() function. But it is even possible?
Here is a verbatim copy of relevant comments and declarations from 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34618\crt\src\vcruntime\vcstartup_internal.h' which is freely installable with Visual Studio 2022:
// When the CRT DLL is used, we must synchronize access to the startup code path. // When all modules loaded in the process are native, there is no opportunity for // problems here. Managed module startup may cause unexpected reentrancy into // the startup code path if something goes wrong. These "locks" are used to // accurately test for those problems. extern "C" bool __cdecl __scrt_acquire_startup_lock(); extern "C" void __cdecl __scrt_release_startup_lock(bool is_nested); These functions are out-of-line variants that do similar stuff to what you quoted. -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public