bsdtar core dumps
sean at mcneil.com
Tue Aug 24 11:51:20 PDT 2004
On Tue, 2004-08-24 at 11:08, Harti Brandt wrote:
> On Tue, 24 Aug 2004, Sean McNeil wrote:
> Sorry to jump in.
> You cannot use a va_list twice. As soon as someone call va_arg() on the
> ap all the aps in the calling functions get invalid. The only thing that
> can and must be done is that the function that did the va_start() must
> call va_end.
> If you need it twice you must make a copy as in the patch below.
> But the function call va_copy must also call va_end() on that copy
> (this seems missing in the patch).
I took the lead from /usr/src/lib/libc/stdio/vfprintf.c
It happens to do a va_copy(orgap,ap) but never does a va_end(orgap).
Either vfprintf.c is incorrect or it is not necessary to call va_end().
One point I would like to make clear - you _can_ use a va_list twice on
architectures that will pass the va_list argument by value (i.e. i386).
This makes it easy to produce faulty code for those architectures that
pass by reference and thus have a side-effect. Since most people here
are developing and testing on x86 machines I would think this problem to
have happened more often than it has.
More information about the freebsd-current