https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6c6d9bee68bc0068cede5…
commit 6c6d9bee68bc0068cede58b41a575fd923b04e01
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon Dec 28 10:47:38 2020 +0100
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Dec 30 19:03:52 2020 +0100
[CRT] Do not call atexit at process initialization
There is no guarantee that the underlying APIs are initialized at this point
CORE-17362
---
sdk/lib/crt/startup/crtexe.c | 12 +++++++++---
sdk/lib/crt/startup/gccmain.c | 2 --
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/sdk/lib/crt/startup/crtexe.c b/sdk/lib/crt/startup/crtexe.c
index efc29191191..a09d4b5b441 100644
--- a/sdk/lib/crt/startup/crtexe.c
+++ b/sdk/lib/crt/startup/crtexe.c
@@ -115,6 +115,10 @@ _CRTALLOC(".CRT$XCAA") _PVFV mingw_pcppinit =
pre_cpp_init;
extern int _MINGW_INSTALL_DEBUG_MATHERR;
+#ifdef __GNUC__
+extern void __do_global_dtors(void);
+#endif
+
static int __cdecl
pre_c_init (void)
{
@@ -211,8 +215,6 @@ int __cdecl mainCRTStartup (void)
return ret;
}
-void __call_atexit();
-
static
__declspec(noinline)
int __cdecl
@@ -326,7 +328,11 @@ __tmainCRTStartup (void)
#endif
mainret = main (argc, argv, envp);
#endif
- __call_atexit();
+
+#ifdef __GNUC__
+ __do_global_dtors();
+#endif
+
if (!managedapp)
exit (mainret);
diff --git a/sdk/lib/crt/startup/gccmain.c b/sdk/lib/crt/startup/gccmain.c
index a1cd04b026e..3370a126947 100644
--- a/sdk/lib/crt/startup/gccmain.c
+++ b/sdk/lib/crt/startup/gccmain.c
@@ -43,8 +43,6 @@ __do_global_ctors (void)
{
__CTOR_LIST__[i] ();
}
-
- atexit (__do_global_dtors);
}
static int initialized = 0;