On Thu, Aug 30, 2012 at 12:29:51PM +0200, Thiago Macieira wrote:
> 2012-08-30  Thiago Macieira <thiago.macie...@intel.com>
> 
>       PR libstdc++/54172
>         * libsupc++/guard.cc (__cxa_guard_acquire): Don't compare_exchange
>         from a finished state back to a waiting state.

This is ok for trunk and 4.7 branch.
The other patches I'd prefer to leave to Richard or Benjamin.

> --- a/libstdc++-v3/libsupc++/guard.cc
> +++ b/libstdc++-v3/libsupc++/guard.cc
> @@ -244,13 +244,13 @@ namespace __cxxabiv1
>      if (__gthread_active_p ())
>        {
>       int *gi = (int *) (void *) g;
> -     int expected(0);
>       const int guard_bit = _GLIBCXX_GUARD_BIT;
>       const int pending_bit = _GLIBCXX_GUARD_PENDING_BIT;
>       const int waiting_bit = _GLIBCXX_GUARD_WAITING_BIT;
>  
>       while (1)
>         {
> +         int expected(0);
>           if (__atomic_compare_exchange_n(gi, &expected, pending_bit, false,
>                                           __ATOMIC_ACQ_REL,
>                                           __ATOMIC_RELAXED))

        Jakub

Reply via email to