Carmelo AMOROSO wrote: > Carmelo AMOROSO wrote: >> [EMAIL PROTECTED] wrote: >>> Author: vda >>> Date: 2008-04-09 12:51:18 -0700 (Wed, 09 Apr 2008) >>> New Revision: 21683 >>> >>> Log: >>> Factor out the core of vprintf() into separate function >>> vprintf_internal, so that: >>> * vprintf() does locking and __STDIO_STREAM_TRANS_TO_WRITE thing, >>> then calls vprintf_internal >>> * vsnprintf, vdprintf.c, vasprintf.c use >>> vprintf_internal directly >>> >>> This makes sprintf faster (since it doesn't do any locking) >>> and stops it from pulling in fseek in static compile. >>> >>> >>> >>> Added: >>> trunk/uClibc/libc/stdio/_vfprintf_internal.c >>> trunk/uClibc/libc/stdio/_vfwprintf_internal.c >>> >>> Modified: >>> trunk/uClibc/libc/stdio/Makefile.in >>> trunk/uClibc/libc/stdio/_stdio.h >>> trunk/uClibc/libc/stdio/_vfprintf.c >>> trunk/uClibc/libc/stdio/vasprintf.c >>> trunk/uClibc/libc/stdio/vdprintf.c >>> trunk/uClibc/libc/stdio/vsnprintf.c >>> trunk/uClibc/libc/stdio/vswprintf.c >>> >>> >> [SNIP] >>> Modified: trunk/uClibc/libc/stdio/_vfprintf.c >>> =================================================================== >>> --- trunk/uClibc/libc/stdio/_vfprintf.c 2008-04-09 11:38:48 UTC >>> (rev 21682) >>> +++ trunk/uClibc/libc/stdio/_vfprintf.c 2008-04-09 19:51:18 UTC >>> (rev 21683) >>> @@ -1198,7 +1198,7 @@ >>> >>> #endif >>> /**********************************************************************/ >>> >>> -#if defined(L_vfprintf) || defined(L_vfwprintf) >>> +#if defined(L__vfprintf_internal) || defined(L__vfwprintf_internal) >>> >>> /* We only support ascii digits (or their USC equivalent codes) in >>> * precision and width settings in *printf (wide) format strings. >>> @@ -1207,14 +1207,15 @@ >>> >>> static size_t _charpad(FILE * __restrict stream, int padchar, size_t >>> numpad); >>> >>> -#ifdef L_vfprintf >>> +#ifdef L__vfprintf_internal >>> >>> -#define VFPRINTF vfprintf >>> +#define VFPRINTF_internal _vfprintf_internal >>> #define FMT_TYPE char >>> #define OUTNSTR _outnstr >>> #define STRLEN strlen >>> #define _PPFS_init _ppfs_init >>> -#define OUTPUT(F,S) fputs_unlocked(S,F) >>> +/* Pulls in fseek: #define OUTPUT(F,S) fputs_unlocked(S,F) */ >>> +#define OUTPUT(F,S) __stdio_fwrite((const unsigned char >>> *)(S),strlen(S),(F)) >> >> Hi Denys, >> while running some test on nptl bracn with runtime assertion enabled, >> I've discoverd that this change is causing uclibc aborting due to an >> assert(bytes) in __stdio_fwrite, while calling fputs_unlocked all works >> fine. I'd like to understand better the rationale behind and I'm >> wondering if the problem is present in trunk with other arch than sh4. >> >> To exploit the problem you simply need to call a printf with a format >> string (i.e. printf("val=%d\n",x) ). >> >> Please let me know your comments, thanks. >> >> Carmelo >> > Hi, > doing further analysis, I've figure out why we fail using > __stdio_fwrite. Basically __stdio_fwrite expects at least 1 bytes. > fputs_unlocked(S,F) calls fwrite_unlocked and this calls __stdio_fwrite > only if bytes to be written are > 0, otherwise simply returs 0 (that is > correct). During the parsing of format spec it could happen that > __stdio_fwrite is called passing an empty string and with assertion > enabled it will abort. > So, I think that using fputs_unlocked is fine, I don't see any other > reasons for calling __stdio_fwrite directly. > > Cheers, > Carmelo
Fix applied in rev 23367. Carmelo >> _______________________________________________ >> uClibc mailing list >> uClibc@uclibc.org >> http://busybox.net/cgi-bin/mailman/listinfo/uclibc >> > > _______________________________________________ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc