From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 703A3397244F; Wed, 17 Jun 2020 21:18:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 703A3397244F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592428696; bh=XyUz+ZuGoHLm3YG6TyJ1j09CrWH1YsWXgK4EvF21ZGo=; h=From:To:Subject:Date:From; b=Cv+ktLJHv3H82wMAtP5Fjm1It1DCQAahbopVFYdPsvh+AvFsPXPf+7TeBNU2Ou9Ud MOTN0FfCk3JJFJorXVPSdaheMgUoaORgHY9HqF/wj2P3cYBPRi16jUDAnV1hqn6DUD /+2nss3A89fEQ4KSCjQJYPrzxCZxp5fCCQQfQgWU= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/ranger] Revert "libstdc++ Enhance thread safety of debug mode iterators" X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Git-Refname: refs/heads/devel/ranger X-Git-Oldrev: fc8f44e06b183707150d4a0937e7c8506984edf1 X-Git-Newrev: ffeb6554bee0f5c3bf2f823aeb1af5c0b3f3cb00 Message-Id: <20200617211816.703A3397244F@sourceware.org> Date: Wed, 17 Jun 2020 21:18:16 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 21:18:16 -0000 https://gcc.gnu.org/g:ffeb6554bee0f5c3bf2f823aeb1af5c0b3f3cb00 commit ffeb6554bee0f5c3bf2f823aeb1af5c0b3f3cb00 Author: François Dumont Date: Mon May 11 14:07:06 2020 +0200 Revert "libstdc++ Enhance thread safety of debug mode iterators" This reverts commit 0b83c4fabb899fdbb3ae60ed75b7004b7859fae9. Diff: --- libstdc++-v3/ChangeLog | 23 ----------------- libstdc++-v3/src/c++11/debug.cc | 57 ++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 52 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8fb6b86474b..a2ff49d9e51 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,26 +1,3 @@ -2020-05-10 François Dumont - - * src/c++/debug.cc - (_Safe_sequence_base::_M_attach_single): Set attached iterator - sequence pointer and version. - (_Safe_sequence_base::_M_detach_single): Reset detached iterator. - (_Safe_iterator_base::_M_attach): Remove attached iterator sequence - pointer and version asignments. - (_Safe_iterator_base::_M_attach_single): Likewise. - (_Safe_iterator_base::_M_detach_single): Remove detached iterator - reset. - (_Safe_iterator_base::_M_singular): Use atomic load to access parent - sequence. - (_Safe_iterator_base::_M_can_compare): Likewise. - (_Safe_iterator_base::_M_get_mutex): Likewise. - (_Safe_local_iterator_base::_M_attach): Remove attached iterator container - pointer and version assignments. - (_Safe_local_iterator_base::_M_attach_single): Likewise. - (_Safe_unordered_container_base::_M_attach_local_single):Set attached - iterator container pointer and version. - (_Safe_unordered_container_base::_M_detach_local_single): Reset detached - iterator. - 2020-05-07 Jonathan Wakely PR libstdc++/94971 (partial) diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index 032e0b50b91..18da9da9c52 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -318,8 +318,6 @@ namespace __gnu_debug _Safe_sequence_base:: _M_attach_single(_Safe_iterator_base* __it, bool __constant) throw () { - __it->_M_sequence = this; - __it->_M_version = _M_version; _Safe_iterator_base*& __its = __constant ? _M_const_iterators : _M_iterators; __it->_M_next = __its; @@ -347,7 +345,6 @@ namespace __gnu_debug _M_const_iterators = __it->_M_next; if (_M_iterators == __it) _M_iterators = __it->_M_next; - __it->_M_reset(); } void @@ -358,7 +355,11 @@ namespace __gnu_debug // Attach to the new sequence (if there is one) if (__seq) - __seq->_M_attach(this, __constant); + { + _M_sequence = __seq; + _M_version = _M_sequence->_M_version; + _M_sequence->_M_attach(this, __constant); + } } void @@ -369,7 +370,11 @@ namespace __gnu_debug // Attach to the new sequence (if there is one) if (__seq) - __seq->_M_attach_single(this, __constant); + { + _M_sequence = __seq; + _M_version = _M_sequence->_M_version; + _M_sequence->_M_attach_single(this, __constant); + } } void @@ -395,7 +400,10 @@ namespace __gnu_debug _M_detach_single() throw () { if (_M_sequence) - _M_sequence->_M_detach_single(this); + { + _M_sequence->_M_detach_single(this); + _M_reset(); + } } void @@ -411,32 +419,20 @@ namespace __gnu_debug bool _Safe_iterator_base:: _M_singular() const throw () - { - auto seq = __atomic_load_n(&_M_sequence, __ATOMIC_ACQUIRE); - return !seq || _M_version != seq->_M_version; - } + { return !_M_sequence || _M_version != _M_sequence->_M_version; } bool _Safe_iterator_base:: _M_can_compare(const _Safe_iterator_base& __x) const throw () { - auto seq = __atomic_load_n(&_M_sequence, __ATOMIC_ACQUIRE); - if (seq && _M_version == seq->_M_version) - { - auto xseq = __atomic_load_n(&__x._M_sequence, __ATOMIC_ACQUIRE); - return xseq && __x._M_version == xseq->_M_version && seq == xseq; - } - - return false; + return (!_M_singular() + && !__x._M_singular() && _M_sequence == __x._M_sequence); } __gnu_cxx::__mutex& _Safe_iterator_base:: _M_get_mutex() throw () - { - auto seq = __atomic_load_n(&_M_sequence, __ATOMIC_ACQUIRE); - return get_safe_base_mutex(seq); - } + { return _M_sequence->_M_get_mutex(); } _Safe_unordered_container_base* _Safe_local_iterator_base:: @@ -451,8 +447,11 @@ namespace __gnu_debug // Attach to the new container (if there is one) if (__cont) - static_cast<_Safe_unordered_container_base*>(__cont) - ->_M_attach_local(this, __constant); + { + _M_sequence = __cont; + _M_version = _M_sequence->_M_version; + _M_get_container()->_M_attach_local(this, __constant); + } } void @@ -463,8 +462,11 @@ namespace __gnu_debug // Attach to the new container (if there is one) if (__cont) - static_cast<_Safe_unordered_container_base*>(__cont) - ->_M_attach_local_single(this, __constant); + { + _M_sequence = __cont; + _M_version = _M_sequence->_M_version; + _M_get_container()->_M_attach_local_single(this, __constant); + } } void @@ -524,8 +526,6 @@ namespace __gnu_debug _Safe_unordered_container_base:: _M_attach_local_single(_Safe_iterator_base* __it, bool __constant) throw () { - __it->_M_sequence = this; - __it->_M_version = _M_version; _Safe_iterator_base*& __its = __constant ? _M_const_local_iterators : _M_local_iterators; __it->_M_next = __its; @@ -553,7 +553,6 @@ namespace __gnu_debug _M_const_local_iterators = __it->_M_next; if (_M_local_iterators == __it) _M_local_iterators = __it->_M_next; - __it->_M_reset(); } }