Bug#609756: vsnprintf segfaults on second attempt with alloca

2011-01-12 Thread Florian Weimer
* Andrew Buckeridge: > C99 only va_copy does help. This is a new one for me. > Does vfnprint destroy the callers ap? Yes, it does. Not on all platforms, but on amd64, for example. Passing va_list as an argument does not make a sufficiently deep copy, so that va_arg in the callee affects subseque

Bug#609756: vsnprintf segfaults on second attempt with alloca

2011-01-12 Thread Andrew Buckeridge
Package: libc6 Version: 2.7-18lenny7 C99 only va_copy does help. This is a new one for me. Does vfnprint destroy the callers ap? Does this break C89 and C90? Gcc did not require -std=c99 or -std=gnu99 to accept va_copy. Assuming was something like #define va_start(ap, last) (ap)=(va_list)(&(las

Bug#609756: vsnprintf segfaults on second attempt with alloca

2011-01-12 Thread Florian Weimer
* Andrew Buckeridge: > int vfprint(int fdout, const char *fmt, va_list ap) > { > int i=NONSTDBUF; > i=vfnprint(fdout, i, fmt, ap); > if(i<-1) > i=vfnprint(fdout, 1-i, fmt, ap); > return i; > } va_copy seems to be missing here. -- Florian Weimer

Bug#609756: vsnprintf segfaults on second attempt with alloca

2011-01-12 Thread Andrew Buckeridge
Package: libc6 Version: 2.7-18lenny7 Changing to alloca malloc does not help. /* fprint.c - unistdio fprint function - Andrew Buckeridge */ #include #include #include #include #include "fprint.h" /* #include */ /* +Ve == bytes written -Ve == bytes required */ int vfnprint(int fdout, int r, c

Bug#609756: vsnprintf segfaults on second attempt with alloca

2011-01-12 Thread Andrew Buckeridge
Package: libc6 Version: 2.7-18lenny7 It is not a heisenbug as suggested by the file name. Its a hard one. It fails, but man page malloc example works. Is this a bug in vsnprintf or my fprint.c? I use alloca which appears to succeed before calling vsnprintf which then segfaults. String is no lar