Skip to content

Instantly share code, notes, and snippets.

@mgexo
mgexo / AboutMixedModeDllNoEntryCrashInVS2022_17_7.md
Last active January 24, 2024 13:58
AboutMixedModeDllNoEntryCrashInVS2022_17_7.md

About Mixed Mode DLL with /NOENTRY crash since Visual Studio 2022 17.7.0 and the global static initializer problem (2024-01-15)

The problem had been originally reported https://developercommunity.visualstudio.com/t/Visual-Studio-2022-1770-CRT-crash-when/10441303.but also in other posts e.g. here https://developercommunity.visualstudio.com/t/CRT-crash-when-loading-mixed-dll-from-N/10559475#T-ND10570501

After further investigation we found out, that the reason is that we used /NOENTRY in our Managed C++ DLL which worked fine with all compilers before we used VS17.7. Now with VS17.7 there seems to be a change on how the atexit table/functionality in the CRT’s utility.cpp works. The functions __scrt_initialize_onexit_tables and __scrt_dllmain_before_initialize must now be called to work correctly whereas in previous VS versions it seems that this was not the case.

The internal analysis was much more comp