[PATCH] libstdc++: Fix wrong thread waking on notify [PR100334]

Jonathan Wakely jwakely@redhat.com
Mon May 10 18:21:10 GMT 2021


On 03/05/21 09:43 -0700, Thomas Rodgers wrote:
>From: Thomas Rodgers <rodgert@twrodgers.com>
>
>This should also be backported to gcc-11

The additional _M_laundered data member changes the object layout.
That isn't safe for the branch. Would it be possible to smuggle that
flag in the least significant bit of the _M_addr member, which is
always aligned to more than one byte? Just on the gcc-11 branch, not
for trunk.


>libstdc++/ChangeLog:
>	* include/bits/atomic_wait.h (__waiter::_M_do_wait_v): loop
>	until observe value change.
>	(__waiter_base::_M_laundered): New member.
>	(__watier_base::_M_notify): Check _M_laundered to determine
>	whether to wake one or all.
>	(__detail::__atomic_compare): Do not implicitly convert
>	result of __buildtin_memcpmp to bool,

Typos, and the description doesn't seem accurate (it wasn't implicitly
converting it to bool, there was always an explicit comparison, but
now it's == rather than !=).

>	(__waiter_base::_S_do_spin_v): Adjust predicate.
>	* testsuite/29_atomics/atomic/wait_notify/100334.cc: New
>	test.


OK for trunk with a fixed changelog, but we need a different patch for
the branch.




More information about the Libstdc++ mailing list