So... If I understand correctly, this problem happens because the __attribute__((destructor)) functions are called from the main thread during exiting the process and at the same time are still running other threads, right?
I would try to think how to address this issue. Maybe I come up with something. On Thursday 17 September 2026 18:27:34 Lasse Collin wrote: > On bug-gnulib, there is a report about a crash in the gdtoa code.[1] I > mentioned this on IRC a few days ago and there was some discussion, but > no solution. > > I built Gnulib's test-c-strtof-mt with mingw-w64 14.0.0 and GCC 16.2.0. > I see the crash with that mingw-w64 version and also after the recent > commits to gdtoa/misc.c. The report on bug-gnulib says that the crash > occurs in 3 out of 10 runs or 1 out of 10 runs. For me it could take > over a hundred runs until it occurred. > > test-c-strtof-mt returns from main() when other threads are still > running and calling the gdtoa code. Returning from main() results in a > call to dtoa_lock_cleanup(). This breaks the CRITICAL_SECTIONs that are > still used by the other threads. As far as I know, returning from > main() when other threads are running isn't (always) a bug. At least > the libc should tolerate that. > > If I remove the function dtoa_lock_cleanup() from gdtoa/misc.c, then > test-c-strtof-mt doesn't crash anymore (the test passed over a thousand > times). Removing it should be OK when the code is used in an > application: the leak occurs when the application is exiting anyway. > > If the code is used in a DLL, unloading the DLL will then leak the > CRITICAL_SECTIONs. However, the locking protects freelist[], and the > memory allocated there isn't freed by anything now, so leaking also the > CRITICAL_SECTIONs might be OK at least as a temporary solution. > > I attached a patch that removes dtoa_lock_cleanup(). It's a hack, but I > know too little about Windows to suggest anything better. > > [1] https://lists.gnu.org/archive/html/bug-gnulib/2026-09/msg00002.html > > -- > Lasse Collin _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
