"Dmitry E. Oboukhov" <firstname.lastname@example.org> writes:
> 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);
> 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.
Should that work at all?
Each invocation of va_start() must be matched by a corresponding invo-
cation of va_end() in the same function. After the call va_end(ap) the
variable ap is undefined. Multiple traversals of the list, each brack-
eted by va_start() and va_end() are possible. va_end() may be a macro
or a function.
You need to call va_start() before the vfprintf or not call va_end().
Does that solve the problem?