Re: bsdtar core dumps

From: Sean McNeil <sean_at_mcneil.com>
Date: Tue, 24 Aug 2004 11:20:00 -0700
On Tue, 2004-08-24 at 11:08, Harti Brandt wrote:
> On Tue, 24 Aug 2004, Sean McNeil wrote:
> 
[snip]
> 
> 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.

Cheers,
Sean
Received on Tue Aug 24 2004 - 16:51:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:08 UTC