>> I have a package which contains a code like following:
>> 
>> #include <stdio.h>
>> 
>> FILE *file_handle;
>> 
>> int foo(int something, const char *fmt, ...)
>> {
>>     // some statements
>>     ....
>>     va_list ap;
>>     int res = vfprintf(file_handle, fmt, ap);
>>     va_end(ap);
>>     return res;
>> }
>> 
>> This code works fine by libc wouldn't be rebuilt (new versions, or new
>> gcc - this moment is ambiguous to me).
>> Then this code begins segfaulting into this place.
>> If we try to rebuild our package, it will begin to work fine again.

GvB> Should that work at all?

GvB> man va_arg:

GvB> va_end()
GvB> Each invocation of va_start() must be matched by a corresponding  invo-
GvB> cation of va_end() in the same function.  After the call va_end(ap) the
GvB> variable ap is undefined.  Multiple traversals of the list, each brack-
GvB> eted  by va_start() and va_end() are possible.  va_end() may be a macro
GvB> or a function.

GvB> You need to call va_start() before the vfprintf or not call va_end().

GvB> Does that solve the problem?

Yes, my first _mail_ contained a mistake, src-code didn't.

Full code here: http://svn.uvw.ru/mhddfs/trunk/src/debug.c
--
... mpd is off

. ''`.                               Dmitry E. Oboukhov
: :’  :   email: un...@debian.org jabber://un...@uvw.ru
`. `~’              GPGKey: 1024D / F8E26537 2006-11-21
  `- 1B23 D4F8 8EC0 D902 0555  E438 AB8C 00CF F8E2 6537

Attachment: signature.asc
Description: Digital signature

Reply via email to