From 277a5aebe0ed91e9cbefb40966e235daba0f1728 Mon Sep 17 00:00:00 2001 From: redi Date: Wed, 26 Oct 2011 23:35:26 +0000 Subject: [PATCH] PR libstdc++/50862 * include/std/condition_variable (condition_variable_any::wait): Avoid terminating if relocking user mutex throws during stack-unwinding. * testsuite/30_threads/condition_variable_any/50862.cc: Add dg-require. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180549 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 7 +++++++ libstdc++-v3/include/std/condition_variable | 8 +++++++- libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1a7d157..b7d9618 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2011-10-27 Jonathan Wakely + + PR libstdc++/50862 + * include/std/condition_variable (condition_variable_any::wait): Avoid + terminating if relocking user mutex throws during stack-unwinding. + * testsuite/30_threads/condition_variable_any/50862.cc: Add dg-require. + 2011-10-25 Jonathan Wakely * include/std/condition_variable (condition_variable_any): Remove diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable index efc4a64..c4e2080 100644 --- a/libstdc++-v3/include/std/condition_variable +++ b/libstdc++-v3/include/std/condition_variable @@ -205,7 +205,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // scoped unlock - unlocks in ctor, re-locks in dtor struct _Unlock { explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); } - ~_Unlock() { _M_lock.lock(); } + ~_Unlock() noexcept(false) + { + if (uncaught_exception()) + __try { _M_lock.lock(); } __catch(...) { } + else + _M_lock.lock(); + } _Lock& _M_lock; }; diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc index db2a5eb..9ca0086 100644 --- a/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc +++ b/libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc @@ -4,6 +4,7 @@ // { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } // { dg-require-cstdint "" } // { dg-require-gthreads "" } +// { dg-require-sched-yield "" } // Copyright (C) 2011 Free Software Foundation, Inc. // -- 2.7.4