This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29496] New: _M_invalidate function is not thread-safe in GLIBCXX_DEBUG mode
- From: "l_heldt at poczta dot onet dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Oct 2006 08:33:27 -0000
- Subject: [Bug c++/29496] New: _M_invalidate function is not thread-safe in GLIBCXX_DEBUG mode
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
_M_invalidate function in safe_iterator.tcc is not thread safe against
_M_detach()/_M_attach() functions from _Safe_iterator_base.
Here is the example of erronous scenario:
Thread1()
{
list::iterator iter;
lock(mutex);
iter = myList.begin();
....
// do something with iter
....
unlock();
}
Thread2()
{
lock(mutex);
myList.erase(myList.begin());
unlock();
}
The problem in this scenario is that while calling erase(), _M_invalidate()
function is called which goes through the list of all iterators without taking
a lock on __gnu_internal::iterator_base_mutex. At the same time another thread
can be deallocating lists iterator - thus calling _M_detach() function.
This leads to a SIGSEGV in _M_invalidate() function.
You should either remove concurrency support from GLIBCXX_DEBUG mode or provide
full support.
--
Summary: _M_invalidate function is not thread-safe in
GLIBCXX_DEBUG mode
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: l_heldt at poczta dot onet dot pl
GCC host triplet: Linux 2.6.9-42.ELsmp #1 SMP
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29496