[Bug libstdc++/60521] New: std::lock_guard ignores adopt_lock strategy

2014-03-14 Thread turchanov at farpost dot com
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
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 guard(mtx, adopt_lock);  // <-- deadlocks!


[Bug libstdc++/60521] std::lock_guard ignores adopt_lock strategy

2014-03-14 Thread turchanov at farpost dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60521

Sergei Turchanov  changed:

   What|Removed |Added

Version|4.8.3   |4.4.7

--- Comment #2 from Sergei Turchanov  ---
My bad! I did not correctly specified target GCC version which should really be
4.4.7 and thus code snippet from mutex is 

...
  lock_guard(mutex_type& __m, adopt_lock_t __a) : _M_device(__m)
  { _M_device.lock(); }
...

which does attempt to lock a mutex.

Now as I see this bug is fixed in mainline so the question is do you plan any
new releases in 4.4.x branch?