[PATCH, libstdc++] Use acquire semantics in case of CAS failure
Thiago Macieira
thiago.macieira@intel.com
Thu Aug 30 10:48:00 GMT 2012
Hello
I detected this issue as I was updating the patches to send to the mailing
list. I have not created a bug report.
When the CAS operation fails and expected == guard_bit, __cxa_guard_acquire
will return immediately indicating that the initialisation has already
succeeded. However, it's missing the acquire barrier for the changes done on
the other thread, to match the release barrier from __cxa_guard_release.
That is:
thread A thread B
load.acq == 0 load.acq == 0
__cxa_guard_acquire __cxa_guard_acquire
CAS(0 -> 256) success
__cxa_guard_release
store.rel(1)
CAS(0 ->256) fails
At this point, we must synchronise with the store-release from thread A.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
Intel Sweden AB - Registration Number: 556189-6027
Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: must-use-acquire-semantics-in-case-of-failure.patch
Type: text/x-patch
Size: 779 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120830/82c9454a/attachment.bin>
More information about the Libstdc++
mailing list