http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55561



--- Comment #26 from Dmitry Vyukov <dvyukov at google dot com> 2012-12-30 
17:07:01 UTC ---

(In reply to comment #25)

> (In reply to comment #24)

> > For testing you can comment out first 2 lines of gomp_ptrlock_get(). That

> > should fix the race in libgomp. It's not a good fix form performance pov, 
> > but

> > should be OK for testing.

> 

> Thanks.. it turns out that gomp_ptrlock_get is actually used from

> 

> gcc/libgomp/config/linux/ptrlock.h:74

> 

> on linux...  is it still sufficient to comment the first if condition only and

> keep the atomic_compare_exchange, or should one directly have the 'return

> gomp_ptrlock_get_slow' ?



Ah, I was looking at config/posix/ptrlock.



For config/linux/ptrlock the changes are:



  if ((uintptr_t) *ptrlock > 2)

    return *ptrlock;

\/\/\/\/\/\/\/\/\/\/\/\/

  uintptr_t v = (uintptr_t)__atomic_load(ptrlock, MEMMODEL_ACQUIRE);

  if (v > 2)

    return v;





  return *ptrlock;

\/\/\/\/\/\/\/\/\/\/\/\/

  return __atomic_load(ptrlock, MEMMODEL_ACQUIRE);





Also loads of intptr needs to be done with __atomic_load(MEMMODEL_RELAXED).

and do_spin() needs to load *addr with __atomic_load(MEMMODEL_RELAXED) as well.

Reply via email to