Message ID | 20160927152915.GA12862@redhat.com |
---|---|
State | New |
Headers | show |
On 27/09/2016 17:29, Jonathan Wakely wrote: > On 20/09/16 09:53 +0100, Jonathan Wakely wrote: >> On 19/09/16 21:56 +0200, François Dumont wrote: >>> Hi >>> >>> Following our conversation here is a much simpler patch. I just >>> consider that all debug containers will have the same alignment. >>> >>> Even if I submit this patch as a whole I will commit into pieces, >>> at least one for the pure cleanup parts and one for the debug.cc >>> change. >>> >>> Among those changes there is: >>> - __gnu_cxx::__scoped_lock(this->_M_get_mutex()); >>> + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); >>> >>> I would appreciate if you could tell me what was happening with >>> the initial expression. I don't understand why it is compiling. I >>> even tried the same in debug.cc and started having compilation errors. >> >> It creates a temporary __scoped_lock, which immediately goes out of >> scope and unlocks the mutex again. This should be fixed on the gcc-5 >> and gcc-6 branches too. > > I'm committing this to the gcc-5 and gcc-6 branches. > > I still had plan to do so but if you have those branches under your hands I appreciate. Thanks, François
commit 5218b515fdb54881d8a2b87c28eb5fd84c52db01 Author: Jonathan Wakely <jwakely@redhat.com> Date: Tue Sep 27 16:22:28 2016 +0100 Fix lifetime of mutex lock in debug iterator * include/debug/safe_iterator.h (_Safe_iterator::operator++()): Fix lifetime of lock. diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index 5368f3b..3f5a7f8 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -296,7 +296,7 @@ namespace __gnu_debug _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), _M_message(__msg_bad_inc) ._M_iterator(*this, "this")); - __gnu_cxx::__scoped_lock(this->_M_get_mutex()); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); ++base(); return *this; }