This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: variadic arguments not thread safe on amd64?
- From: Ian Lance Taylor <iant at google dot com>
- To: Matt Provost <mprovost at termcap dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 27 Apr 2009 22:16:34 -0700
- Subject: Re: variadic arguments not thread safe on amd64?
- References: <20090428033741.GO2473@newinst.layeredtech.com>
Matt Provost <mprovost@termcap.net> writes:
> Is there a portable way to pass a va_list between threads?
This question would be more appropriate for the gcc-help@gcc.gnu.org
mailing list.
The answer is no: you can not pass va_list values between threads. If
you think about it you will realize that the va_list value can not hold
the complete set of variable arguments, as there is no way to know how
many there are. Therefore, if you pass enough variable arguments to a
function, it is guaranteed that some will be on the stack. You can not
reliably pass a reference to the stack of one thread to another thread,
because the first thread might exit before the second thread runs.
Ian