This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: private static object construction bug?




--On Monday, August 05, 2002 03:50:12 PM -0700 Zack Weinberg <zack@codesourcery.com> wrote:

On Mon, Aug 05, 2002 at 01:58:18PM -0700, Mark Mitchell wrote:

 if (!guard) {
   __cxa_guard_acquire (&guard); // I forget the exact name.
   // Construct variable.
   __cxa_guard_release (&guard):
 }
This sequence has two different races.

Yes; I was overly simplistic.  You are of course correct.

It is likely that the ABI standard does specify something like this,
but I wanted to make sure people understood that thread-safe object
construction is not as simple as you made it look.  (The guard
variable can't be a simple integer, either; it needs to be a structure
containing an integer and a mutex.)
Yes.  The ABI says that guard is 64 bits long, and that one of the
bytes is a boolean.  (Our current implementation just twiddles that
byte.)  The idea is that __cxa_guard_acquire twiddles the byte in
a thread-safe way.

Thanks for clarifying.

--
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]