It works fine on mingw32 and mingw64, but on MSYS it goes wrong when calling pthread_mutex_lock. In the following gdb session, the first line is from my code; the rest is tracing through gnulib code.
(gdb) n 171 char *old_locale = setlocale(LC_ALL, NULL); (gdb) s rpl_setlocale (category=0, locale=0x0) at setlocale.c:72 72 if (locale == NULL) (gdb) 73 return (char *) setlocale_null (category); (gdb) setlocale_null (category=0) at setlocale_null.c:302 302 { (gdb) 317 if (category == LC_ALL) (gdb) 325 if (setlocale_null_r (LC_ALL, buf, sizeof (buf))) (gdb) 0x00000005e4883a3c in setlocale_null_r (bufsize=<optimized out>, buf=<optimized out>, category=<optimized out>) at setlocale_null.c:294 294 return setlocale_null_with_lock (category, buf, bufsize); (gdb) 325 if (setlocale_null_r (LC_ALL, buf, sizeof (buf))) (gdb) setlocale_null_r (bufsize=3221, buf=0xffffbd80 "", category=0) at setlocale_null.c:294 294 return setlocale_null_with_lock (category, buf, bufsize); (gdb) setlocale_null_with_lock (category=category@entry=0, buf=buf@entry=0xffffbd80 "", bufsize=bufsize@entry=3221) at setlocale_null.c:228 228 if (pthread_in_use()) (gdb) 230 pthread_mutex_t *lock = gl_get_setlocale_null_lock (); (gdb) gl_get_setlocale_null_lock () at setlocale-lock.c:105 105 return &mutex; (gdb) setlocale_null_with_lock (category=category@entry=0, buf=buf@entry=0xffffbd80 "", bufsize=bufsize@entry=3221) at setlocale_null.c:233 233 if (pthread_mutex_lock (lock)) (gdb) 0x0000000600000000 in ?? () (gdb) q I have linked with LIBTHREAD, and in any case it's empty on MSYS. -- https://rrt.sc3d.org