vswprintf lacks mutex init

Thomas Rauscher trauscher at loytec.com
Thu Sep 23 07:02:05 UTC 2010


Hi,

it seems that vswprintf lacks the initialization of the STDIO mutex.
At least on ARM/NPTL, calling this function blocks sometimes.

The following patch solved the problem for me (code copied from vsnprintf.c).

diff -ruN uClibc.orig/libc/stdio/vswprintf.c uClibc/libc/stdio/vswprintf.c
--- uClibc.orig/libc/stdio/vswprintf.c  2010-09-20 15:03:17.000000000 +0200
+++ uClibc/libc/stdio/vswprintf.c       2010-09-22 17:20:00.000000000 +0200
@@ -39,6 +39,11 @@
        __INIT_MBSTATE(&(f.__state));
 #endif /* __STDIO_MBSTATE */
 
+#if (defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__)) && defined(__UCLIBC_HAS_THREADS__)
+       f.__user_locking = 1;       /* Set user locking. */
+       STDIO_INIT_MUTEX(f.__lock);
+#endif
+
        f.__nextopen = NULL;
 
        if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) {

-- 
Thomas Rauscher


More information about the uClibc mailing list