https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108288

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've tried to reproduce this, but it depends on the addresses of the
_Safe_iterator objects that get created, because they'll use different mutexes
unless their addresses collide in the hash function.

Would you be able to test this patch?

--- a/libstdc++-v3/include/debug/safe_iterator.h
+++ b/libstdc++-v3/include/debug/safe_iterator.h
@@ -761,12 +761,9 @@ namespace __gnu_debug
       _Safe_iterator
       operator++(int) _GLIBCXX_NOEXCEPT
       {
-       _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(),
-                             _M_message(__msg_bad_inc)
-                             ._M_iterator(*this, "this"));
-       __gnu_cxx::__scoped_lock __l(this->_M_get_mutex());
-       return _Safe_iterator(this->base()++, this->_M_sequence,
-                             _Attach_single());
+       _Safe_iterator __ret = *this;
+       ++*this;
+       return __ret;
       }

       // ------ Bidirectional iterator requirements ------
@@ -788,12 +785,9 @@ namespace __gnu_debug
       _Safe_iterator
       operator--(int) _GLIBCXX_NOEXCEPT
       {
-       _GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(),
-                             _M_message(__msg_bad_dec)
-                             ._M_iterator(*this, "this"));
-       __gnu_cxx::__scoped_lock __l(this->_M_get_mutex());
-       return _Safe_iterator(this->base()--, this->_M_sequence,
-                             _Attach_single());
+       _Safe_iterator __ret = *this;
+       --*this;
+       return __ret;
       }

       // ------ Random access iterator requirements ------

Reply via email to