This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/60521] New: std::lock_guard ignores adopt_lock strategy
- From: "turchanov at farpost dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Mar 2014 07:29:22 +0000
- Subject: [Bug libstdc++/60521] New: std::lock_guard ignores adopt_lock strategy
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60521
Bug ID: 60521
Summary: std::lock_guard ignores adopt_lock strategy
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: blocker
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: turchanov at farpost dot com
lock_guard created with constructor lock_guard::lock_guard(mutex_type& m,
adopt_lock_t tag) must adopt already locked mutex. But current implementation
ignores completely this fact and tries to lock passed mutex unconditionally:
template<typename _Mutex>
class lock_guard {
...
lock_guard(mutex_type& __m, adopt_lock_t) : _M_device(__m)
{ } // calling thread owns mutex
...
};
and given the fact that mutex type is not a recursive mutex this code sequence
produces a dead-lock:
mutex mtx;
mtx.lock();
lock_guard<mutex> guard(mtx, adopt_lock); // <-- deadlocks!