re PR libstdc++/50862 (deadlock in std::condition_variable_any)

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.

From-SVN: r180549
This commit is contained in:
Jonathan Wakely 2011-10-26 23:35:26 +00:00 committed by Jonathan Wakely
parent e7604cc480
commit 28c2f60e96
3 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2011-10-27 Jonathan Wakely <jwakely.gcc@gmail.com>
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 <jwakely.gcc@gmail.com>
* include/std/condition_variable (condition_variable_any): Remove

View File

@ -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;
};

View File

@ -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.
//