Running a gnulib testdir on mingw 13.0.0 (UCRT), I see an occasional crash
of the c-strtof and c-strtod multithreading tests:

LC_ALL=French_France.65001 ./test-c-strtof-mt.exe
crashes in ca. 3 out of 10 runs.

LC_ALL=French_France.65001 ./test-c-strtod-mt.exe
crashes in ca. 1 out of 10 runs.

The gdb backtrace:
Thread 6 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 5604.0x8c8]
0x00007ff9260749e6 in ntdll!RtlWaitOnAddress () from 
C:\WINDOWS\SYSTEM32\ntdll.dll
(gdb) where
#0  0x00007ff9260749e6 in ntdll!RtlWaitOnAddress () from 
C:\WINDOWS\SYSTEM32\ntdll.dll
#1  0x00007ff92603fcb4 in ntdll!RtlEnterCriticalSection () from 
C:\WINDOWS\SYSTEM32\ntdll.dll
#2  0x00007ff92603fae2 in ntdll!RtlEnterCriticalSection () from 
C:\WINDOWS\SYSTEM32\ntdll.dll
#3  0x00007ff63ee902c7 in __Bfree_D2A (v=0x7ff63ee9cc28 <private_mem+72>)
    at C:/M/B/src/mingw-w64/mingw-w64-crt/gdtoa/misc.c:172
#4  0x00007ff63ee8bff3 in __pformat_float (x=<optimized out>, 
stream=stream@entry=0x157fda0)
    at C:/M/B/src/mingw-w64/mingw-w64-crt/stdio/mingw_pformat.c:1580
#5  0x00007ff63ee8cea4 in __mingw_pformat (flags=flags@entry=16384, 
dest=dest@entry=0x157fe9b,
    max=max@entry=0, fmt=0x7ff63ee93005 "", fmt@entry=0x7ff63ee93000 "%#.0f",
    argv=<optimized out>, argv@entry=0x157fe80 "")
    at C:/M/B/src/mingw-w64/mingw-w64-crt/stdio/mingw_pformat.c:2745
#6  0x00007ff63ee880f4 in __mingw_sprintf (buf=buf@entry=0x157fe9b "1,",
    fmt=fmt@entry=0x7ff63ee93000 "%#.0f")
    at C:/M/B/src/mingw-w64/mingw-w64-crt/stdio/mingw_sprintf.c:53
#7  0x00007ff63ee81470 in thread3_func (arg=<optimized out>) at 
test-c-strtof-mt.c:87
#8  0x00007ff63ee824b6 in wrapper_func (varg=0x762a40) at windows-thread.c:136
#9  0x00007ff923f51bb2 in ucrtbase!_configthreadlocale () from 
C:\WINDOWS\System32\ucrtbase.dll
#10 0x00007ff925537374 in KERNEL32!BaseThreadInitThunk () from 
C:\WINDOWS\System32\kernel32.dll
#11 0x00007ff92605cc91 in ntdll!RtlUserThreadStart () from 
C:\WINDOWS\SYSTEM32\ntdll.dll
#12 0x0000000000000000 in ?? ()

It shows that the problem occurs in mingw's internal lock that
protects gdtoa resources. It's unrelated to the locale changes done
by the test program.

There's no easy workaround. We can only document it:


2026-09-02  Bruno Haible  <[email protected]>

        Document possible *printf crash on mingw.
        * doc/posix-functions/*printf.texi: Document the mingw multithreading
        bug.

diff --git a/doc/posix-functions/fprintf.texi b/doc/posix-functions/fprintf.texi
index 8e6ef3a3e9..c0c54f79dc 100644
--- a/doc/posix-functions/fprintf.texi
+++ b/doc/posix-functions/fprintf.texi
@@ -162,6 +162,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 Attempting to write to a read-only stream fails with @code{EOF} but
 does not set the error flag for @code{ferror} on some platforms:
 glibc 2.13, cygwin 1.7.9.
diff --git a/doc/posix-functions/fwprintf.texi 
b/doc/posix-functions/fwprintf.texi
index da941b285f..b9b285b252 100644
--- a/doc/posix-functions/fwprintf.texi
+++ b/doc/posix-functions/fwprintf.texi
@@ -66,6 +66,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 On some platforms, this function does not set @code{errno} or the
 stream error indicator on attempts to write to a read-only stream:
 Cygwin 1.7.9.
diff --git a/doc/posix-functions/printf.texi b/doc/posix-functions/printf.texi
index 47167fdea2..bcdc00e0b3 100644
--- a/doc/posix-functions/printf.texi
+++ b/doc/posix-functions/printf.texi
@@ -166,6 +166,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 Attempting to write to a read-only stream fails with @code{EOF} but
 does not set the error flag for @code{ferror} on some platforms:
 glibc 2.13, cygwin 1.7.9.
diff --git a/doc/posix-functions/snprintf.texi 
b/doc/posix-functions/snprintf.texi
index ba2578b2ba..f7573a1dc8 100644
--- a/doc/posix-functions/snprintf.texi
+++ b/doc/posix-functions/snprintf.texi
@@ -157,4 +157,8 @@
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
+@item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
 @end itemize
diff --git a/doc/posix-functions/sprintf.texi b/doc/posix-functions/sprintf.texi
index 2948797c6b..e1ce48b151 100644
--- a/doc/posix-functions/sprintf.texi
+++ b/doc/posix-functions/sprintf.texi
@@ -134,4 +134,8 @@
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
+@item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
 @end itemize
diff --git a/doc/posix-functions/swprintf.texi 
b/doc/posix-functions/swprintf.texi
index 6c9a0dfde5..870375c95d 100644
--- a/doc/posix-functions/swprintf.texi
+++ b/doc/posix-functions/swprintf.texi
@@ -104,4 +104,8 @@
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
+@item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
 @end itemize
diff --git a/doc/posix-functions/vfprintf.texi 
b/doc/posix-functions/vfprintf.texi
index 52b9491a63..56e7818dc5 100644
--- a/doc/posix-functions/vfprintf.texi
+++ b/doc/posix-functions/vfprintf.texi
@@ -162,6 +162,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 Attempting to write to a read-only stream fails with @code{EOF} but
 does not set the error flag for @code{ferror} on some platforms:
 glibc 2.13, cygwin 1.7.9.
diff --git a/doc/posix-functions/vfwprintf.texi 
b/doc/posix-functions/vfwprintf.texi
index 9931e374f4..6064d3f29e 100644
--- a/doc/posix-functions/vfwprintf.texi
+++ b/doc/posix-functions/vfwprintf.texi
@@ -66,6 +66,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 On some platforms, this function does not set @code{errno} or the
 stream error indicator on attempts to write to a read-only stream:
 Cygwin 1.7.9.
diff --git a/doc/posix-functions/vprintf.texi b/doc/posix-functions/vprintf.texi
index 97bf877a1a..d08d28c1e4 100644
--- a/doc/posix-functions/vprintf.texi
+++ b/doc/posix-functions/vprintf.texi
@@ -162,6 +162,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 Attempting to write to a read-only stream fails with @code{EOF} but
 does not set the error flag for @code{ferror} on some platforms:
 glibc 2.13, cygwin 1.7.9.
diff --git a/doc/posix-functions/vsnprintf.texi 
b/doc/posix-functions/vsnprintf.texi
index f23e3967a5..f6f150e005 100644
--- a/doc/posix-functions/vsnprintf.texi
+++ b/doc/posix-functions/vsnprintf.texi
@@ -155,4 +155,8 @@
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
+@item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
 @end itemize
diff --git a/doc/posix-functions/vsprintf.texi 
b/doc/posix-functions/vsprintf.texi
index 907bf74443..79b7e7b756 100644
--- a/doc/posix-functions/vsprintf.texi
+++ b/doc/posix-functions/vsprintf.texi
@@ -134,4 +134,8 @@
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
+@item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
 @end itemize
diff --git a/doc/posix-functions/vswprintf.texi 
b/doc/posix-functions/vswprintf.texi
index f5bc1b46ff..3c2e95dcde 100644
--- a/doc/posix-functions/vswprintf.texi
+++ b/doc/posix-functions/vswprintf.texi
@@ -67,4 +67,8 @@
 When formatting an integer with grouping flag, this function inserts thousands
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
+@item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
 @end itemize
diff --git a/doc/posix-functions/vwprintf.texi 
b/doc/posix-functions/vwprintf.texi
index 711da00d50..774efea35c 100644
--- a/doc/posix-functions/vwprintf.texi
+++ b/doc/posix-functions/vwprintf.texi
@@ -69,6 +69,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 On some platforms, this function does not set @code{errno} or the
 stream error indicator on attempts to write to a read-only stream:
 Cygwin 1.7.9.
diff --git a/doc/posix-functions/wprintf.texi b/doc/posix-functions/wprintf.texi
index c7a6a13b41..fc6cbbba90 100644
--- a/doc/posix-functions/wprintf.texi
+++ b/doc/posix-functions/wprintf.texi
@@ -69,6 +69,10 @@
 separators even in the "C" locale on some platforms:
 NetBSD 5.1.
 @item
+This function is not thread-safe (simultaneous formatting of floating-point
+numbers in different threads may crash the program) on some platforms:
+mingw 13.
+@item
 On some platforms, this function does not set @code{errno} or the
 stream error indicator on attempts to write to a read-only stream:
 Cygwin 1.7.9.




Reply via email to