On Fri, 30 Oct 2020, Liu Hao wrote:
I have a little hazy memory about this so feel welcome to correct me:
0) The user program calls `exit()` or returns from `main()`.
1) `exit()` is called, which invokes callbacks registered with `atexit()`
in reverse order.
If you're using UCRT, the callback (tls_atexit_callback in tls_atexit.c)
registered by _register_thread_local_exe_atexit_callback gets executed.
This is a callback that gets executed _before_ running any atexit
functions, and allows UCRT builds to get TLS destructors executed at the
right spot. Unfortunately, the emulation of
_register_thread_local_exe_atexit_callback for msvcrt.dll isn't perfect -
maybe it's possible to make it better somehow?
One way would be to change the atexit() function in crt/crtexe.c to create
a local list of funtions registered by atexit, just adding one single
function to the CRT's atexit() list, and in that function, first execute
the callback defined by _register_thread_local_exe_atexit_callback if set,
then all functions registered by atexit().
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public