libstdc++ Enhance thread safety of debug mode iterators
authorFrançois Dumont <fdumont@gcc.gnu.org>
Sat, 29 Feb 2020 17:22:55 +0000 (18:22 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Sun, 10 May 2020 21:01:41 +0000 (23:01 +0200)
commit0b83c4fabb899fdbb3ae60ed75b7004b7859fae9
treecaa0c24850710ec8e67b8088d17a1ab7b147d179
parent92ed82367e7ccf5e031e9cb7c653c14a2d64ca89
libstdc++ Enhance thread safety of debug mode iterators

Avoids race condition when checking for an iterator to be singular or
to be comparable to another iterator.

* 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.
libstdc++-v3/ChangeLog
libstdc++-v3/src/c++11/debug.cc