]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/50862 (deadlock in std::condition_variable_any)
authorJonathan Wakely <jwakely.gcc@gmail.com>
Wed, 26 Oct 2011 23:35:26 +0000 (23:35 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 26 Oct 2011 23:35:26 +0000 (00:35 +0100)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/condition_variable
libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc

index 1a7d157b4b3eb9ab856617d4bb18b5bc100fbadc..b7d9618f00ebcba3651413b4a338c9a4fba6a0d7 100644 (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
index efc4a64ef1d221574c0421f060a73bcfeee91413..c4e2080165d72f0e02a4062c5ba4e7859bd2579f 100644 (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;
        };
 
index db2a5eb71b282a41aaa33a0e3e0425c0ef3167c7..9ca008681b6ed7c6f7be0ecd2d5c93e7f064d3eb 100644 (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.
 //