On Fri, May 06, 2005 at 12:30:33AM +0200, Leopold Palomo Avellaneda wrote: > I would like to know if is a problem of the 64 arch or what. I'm no > on this list, so please, make a CC to me, It works fine on IA64. This sort of thing intrigues me, and I have an AMD64 around, so I had a look at the libcoin code. In src/base/string.c:cc_string_sprintf() you call cc_string_vsprintf() to put the string into the buffer. This makes repeated called to vsnprintf() (through the small wrapper src/tidbits.c:coin_vsnprintf()) to see if the string fits or not and grow the string object. That's where your problem is. With AMD64, two calls to vsnprintf() with the same va_arg value cause a segfault. On IA64 at least, this doesn't happen. A minimal test case is attached which works on IA64 and segfaults on AMD64. I would suggest that you investigate this a little further, probably making sure that the IA64 behaviour follows the standard (someone on this list might know that) and that it hasn't been fixed in some later version of glibc. Otherwise file a bug at http://sources.redhat.com/bugzilla/enter_bug.cgi?product=glibc (please CC me on anything so I can see where the problem is). Thanks, -i ianw@gelato.unsw.edu.au http://www.gelato.unsw.edu.au
#include <stdio.h> #include <stdlib.h> #include <stdarg.h> void test_vsnprintf(char * dst, unsigned int n, const char * fmtstr, va_list args) { vsnprintf(dst, (size_t)n, fmtstr, args); vsnprintf(dst, (size_t)n, fmtstr, args); } void test(char * dst, unsigned int n, const char * fmtstr, ...) { va_list argptr; va_start(argptr, fmtstr); test_vsnprintf(dst, n, fmtstr, argptr); va_end(argptr); } int main(void) { char array[100]; test(array, 100, "%s%s", "hello", "how are you"); }
Attachment:
signature.asc
Description: Digital signature