From mboxrd@z Thu Jan 1 00:00:00 1970
Return-Path:
Received: by sourceware.org (Postfix, from userid 2181)
id 42A1D3858C3A; Thu, 9 Dec 2021 23:27:22 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42A1D3858C3A
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
From: Jonathan Wakely
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-5877] libstdc++: Allow std::condition_variable waits to be
cancelled [PR103382]
X-Act-Checkin: gcc
X-Git-Author: Jonathan Wakely
X-Git-Refname: refs/heads/master
X-Git-Oldrev: db5fa0837e464b595a3d63766060bae1c9ac5ccc
X-Git-Newrev: 9e18a25331fa25c3907249fede65a02c6817b06e
Message-Id: <20211209232722.42A1D3858C3A@sourceware.org>
Date: Thu, 9 Dec 2021 23:27:22 +0000 (GMT)
X-BeenThere: gcc-cvs@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Gcc-cvs mailing list
List-Unsubscribe: ,
List-Archive:
List-Help:
List-Subscribe: ,
X-List-Received-Date: Thu, 09 Dec 2021 23:27:22 -0000
https://gcc.gnu.org/g:9e18a25331fa25c3907249fede65a02c6817b06e
commit r12-5877-g9e18a25331fa25c3907249fede65a02c6817b06e
Author: Jonathan Wakely
Date: Tue Dec 7 15:11:15 2021 +0000
libstdc++: Allow std::condition_variable waits to be cancelled [PR103382]
std::condition_variable::wait(unique_lock&) is incorrectly marked
noexcept, which means that the __forced_unwind exception used by NPTL
cancellation will terminate the process. It should allow exceptions to
pass through, so that a thread can be cleanly cancelled when waiting on
a condition variable.
The new behaviour is exported as a new version of the symbol, to avoid
an ABI break for existing code linked to the non-throwing definition of
the function. Code linked against older releases will have a reference
to the @GLIBCXX_3.4.11 version, andcode compiled against the new
libstdc++ will get a reference to the @@GLIBCXX_3.4.30 version.
libstdc++-v3/ChangeLog:
PR libstdc++/103382
* config/abi/pre/gnu.ver (GLIBCXX_3.4.11): Do not export old
symbol if .symver renaming is supported.
(GLIBCXX_3.4.30): Export new symbol if .symver renaming is
supported.
* doc/xml/manual/evolution.xml: Document change.
* doc/html/manual/api.html: Regenerate.
* include/bits/std_mutex.h (__condvar::wait, __condvar::wait_until):
Remove noexcept.
* include/std/condition_variable (condition_variable::wait):
Likewise.
* src/c++11/condition_variable.cc (condition_variable::wait):
Likewise.
* src/c++11/compatibility-condvar.cc (__nothrow_wait_cv::wait):
Define nothrow wrapper around std::condition_variable::wait and
export the old symbol as an alias to it.
* testsuite/30_threads/condition_variable/members/103382.cc: New test.
Diff:
---
libstdc++-v3/config/abi/pre/gnu.ver | 12 +++-
libstdc++-v3/doc/html/manual/api.html | 5 ++
libstdc++-v3/doc/xml/manual/evolution.xml | 7 +++
libstdc++-v3/include/bits/std_mutex.h | 6 +-
libstdc++-v3/include/std/condition_variable | 2 +-
libstdc++-v3/src/c++11/compatibility-condvar.cc | 31 ++++++++++
libstdc++-v3/src/c++11/condition_variable.cc | 2 +-
.../condition_variable/members/103382.cc | 66 ++++++++++++++++++++++
8 files changed, 125 insertions(+), 6 deletions(-)
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 8f3c7b3827e..b747351a1b9 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1285,7 +1285,6 @@ GLIBCXX_3.4.11 {
# condition_variable
_ZNSt18condition_variable10notify_allEv;
_ZNSt18condition_variable10notify_oneEv;
- _ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE;
_ZNSt18condition_variableC1Ev;
_ZNSt18condition_variableC2Ev;
_ZNSt18condition_variableD1Ev;
@@ -1295,6 +1294,12 @@ GLIBCXX_3.4.11 {
_ZNSt22condition_variable_anyD1Ev;
_ZNSt22condition_variable_anyD2Ev;
+#ifndef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
+ # The original definition of this symbol gets versioned as @GLIBCXX_3.4.11
+ # if ".symver" is supported, or as @@GLIBCXX_3.4.11 otherwise.
+ _ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE;
+#endif
+
# thread
_ZNSt6thread4joinEv;
_ZNSt6thread6detachEv;
@@ -2401,6 +2406,11 @@ GLIBCXX_3.4.30 {
_ZSt21__glibcxx_assert_fail*;
+#ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
+ # The new definition of this symbol gets versioned as @@GLIBCXX_3.4.30
+ _ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE;
+#endif
+
} GLIBCXX_3.4.29;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html
index 00701fa1044..1c7fdaa7394 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -450,4 +450,9 @@ options for --enable-libstdcxx-allocator
were remove
For the new
option, std::allocator
no longer derives from __gnu_cxx::new_allocator
;
they both derive from std::__new_allocator
instead.
+
+std::condition_variable::wait
changed to be
+noexcept(false)
to allow thread cancellation exceptions to
+be thrown from pthread_cond_wait
without aborting
+the process.