This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: [PATCH, libstdc++] Fix PR54172


> The attached patch fixes a race condition in __cxa_guard_acquire, a
> regression from 4.6. When the code was refactored to use the new
> atomic intrinsics, the fact that __atomic_compare_exchange_n updates
> the "expected" variable with the current value was missed.
> 
> That causes the loop to possibly overwrite a successful
> initialisation and re- start the initialisation phase. The bug report
> has a gdb trace with a watchpoint showing the guard variable
> transitioning
> 
> 	0 (uninit) -> 256 (pending) -> 1 (done) -> 256 (pending) -> 1
> (done)
> 
> This situation can happen if both CAS fail in given thread: the first
> because the other thread started the initialisation and the second
> because the initialisation succeeded.

This is ok.

-benjamin


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