Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Aug 2004 11:20:00 -0700
From:      Sean McNeil <sean@mcneil.com>
To:        Harti Brandt <harti@freebsd.org>
Cc:        current@freebsd.org
Subject:   Re: bsdtar core dumps
Message-ID:  <1093371600.10464.23.camel@server.mcneil.com>
In-Reply-To: <20040824200225.V517@beagle.kn.op.dlr.de>
References:  <1092777586.92327.9.camel@server.mcneil.com> <20040817213813.GE3827@gothmog.gr><4127841D.6050104@freebsd.org> <1093369220.10362.6.camel@server.mcneil.com> <20040824200225.V517@beagle.kn.op.dlr.de>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1093371600.10464.23.camel>