gcc/libstdc++-v3
Tomasz Kamiński 59889eaa2b libstdc++: Make atomic<shared_ptr<T>>::wait sensitive to stored pointer only changes [PR118757]
Previously, atomic<shared_ptr<T>>::wait (and the weak_ptr version) was
equivalent to waiting directly on _M_val, which corresponds to the pointer
to the control block (_M_pi). Consequently, wakeups were not triggered if
the stored pointer value was changed to a pointer that uses the same control
block but stores pointer to a different object. Such a pointer can be
constructed using an aliasing constructor.

To address this, wait now uses a generic proxy wait
std::__atomic_wait_address function, which supports waiting until any
predicate is satisfied. The provided predicate now compares both the control
block (_M_pi) and the stored pointer (_M_ptr). Comparing the latter requires
locking the pointer.

Since this function operates on raw pointers, the type of _M_val was changed
from __atomic_base<uintptr_t> to uintptr_t. Invocations of the corresponding
member functions are now replaced with direct use of __atomic builtins.

	PR libstdc++/118757

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (_Atomic_count::_M_wait_unlock):
	Add parameter capturing reference to _M_ptr. Reimplement in terms
	of __atomic_wait_address.
	(_Atomic_count::~_Atomic_count, _Atomic_count::lock)
	(_Atomic_count::unlock, _Atomic_count::_M_swap_unlock): Replace
	invocation of atomic member funcitons with __atomic builtins.
	(_Atomic_count::notify_one, _Atomic_count::notify_all):
	Use __atomic_notify_address.
	(_Sp_atomic::element_type): Define.
	(_Sp_atomic::_M_val): Change type to uintptr_t.
	(_Sp_atomic::wait): Pass _M_ptr to _M_wait_unlock.
	* python/libstdcxx/v6/printers.py:
	* testsuite/20_util/shared_ptr/atomic/pr118757.cc: New test.
	* testsuite/20_util/weak_ptr/pr118757.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-10-14 14:38:30 +02:00
..
config libstdc++: Remove unused config/cpu/i486/atomicity.h file 2025-10-08 17:06:21 +01:00
doc libstdc++: Update Autoconf manual link 2025-10-11 12:18:56 +02:00
include libstdc++: Make atomic<shared_ptr<T>>::wait sensitive to stored pointer only changes [PR118757] 2025-10-14 14:38:30 +02:00
libsupc++ *: regenerate autotools 2025-10-05 17:14:49 +01:00
po *: regenerate autotools 2025-10-05 17:14:49 +01:00
python libstdc++: Make atomic<shared_ptr<T>>::wait sensitive to stored pointer only changes [PR118757] 2025-10-14 14:38:30 +02:00
scripts libstdc++: Implement std::chrono::current_zone() for Windows [PR108409] 2025-07-15 16:49:43 +01:00
src libstdc++: Implement submdspan_mapping_result. [PR110352] 2025-10-08 12:39:44 +02:00
testsuite libstdc++: Make atomic<shared_ptr<T>>::wait sensitive to stored pointer only changes [PR118757] 2025-10-14 14:38:30 +02:00
.editorconfig libstdc++: editorconfig: Adjust wildcard patterns 2024-12-07 08:49:26 +00:00
ChangeLog Daily bump. 2025-10-14 00:20:06 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013 Rotate ChangeLog files. 2025-01-02 11:06:31 +01:00
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
ChangeLog-2020
ChangeLog-2021
ChangeLog-2022 Rotate ChangeLog files. 2025-01-02 11:06:31 +01:00
ChangeLog-2023 Rotate ChangeLog files. 2025-01-02 11:06:31 +01:00
ChangeLog-2024 Rotate ChangeLog files. 2025-01-02 11:06:31 +01:00
Makefile.am Update copyright years. 2025-01-02 11:59:57 +01:00
Makefile.in *: regenerate autotools 2025-10-05 17:14:49 +01:00
README
acinclude.m4 libstdc++: Implement P3107R5 optimizations for std::print [PR121790] 2025-10-10 09:00:22 +02:00
aclocal.m4 *: regenerate autotools 2025-10-05 17:14:49 +01:00
config.h.in libstdc++: Implement P3107R5 optimizations for std::print [PR121790] 2025-10-10 09:00:22 +02:00
configure libstdc++: Implement P3107R5 optimizations for std::print [PR121790] 2025-10-10 09:00:22 +02:00
configure.ac libstdc++: Implement P3107R5 optimizations for std::print [PR121790] 2025-10-10 09:00:22 +02:00
configure.host all: Fix "specifc", "costant" and "constat" typos in comments 2025-10-07 15:03:42 +01:00
crossconfig.m4
fragment.am
linkage.m4

README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.