This is the mail archive of the gcc-patches@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: RFC: PATCH for thread-safe C++ static local initialization


>           static <type> guard;
>           if (!guard.first_byte) {
>             if (__cxa_guard_acquire (&guard)) {
>               bool flag = false;
>               try {
>                 // Do initialization.
>                 flag = true; __cxa_guard_release (&guard);
>                 // Register variable for destruction at end of program.
>               } catch {
>                 if (!flag) __cxa_guard_abort (&guard);
>               }
>             }
>           }

I assume that this is just my misunderstanding of the inner workings of how 
the guard works, but isn't there

a) a second if(!guard.first_byte) missing inside the guarded block? (Some 
other thread may have set it between out checking for the flag and getting to 
the __cxa_guard_acquire.)

b) code missing to set guard.first_byte to something nonzero?

In any case, the main point of this mail is to point you (and this archived 
thread) to
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13684
which you are doubtlessly aware of and which discusses this stuff.

Thanks
  Wolfgang
 
-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/


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