http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52604
--- Comment #9 from Laurent Aflonsi <laurent.alfonsi at st dot com> 2012-04-12
15:05:25 UTC ---
Paolo,
I ve discovered that the encoding of M_key is encoded differently for each
thread-implementation. On pthread implementation M_key is an integer, whereas
on others it is pointers. So, in pthread 0 is a legal thread key: So zeroing
M_key and testing if(M_key) is simply wrong.
The M_thread_freelist zeroing seems legal and is enough to avoid the above
valgrind error. I am now testing with this fix only:
============================
--- libstdc++-v3/src/mt_allocator.cc
+++ libstdc++-v3/src/mt_allocator.cc
@@ -47,7 +47,8 @@
if (_M_thread_freelist_array)
{
__gthread_key_delete(_M_key);
::operator delete(static_cast<void*>(_M_thread_freelist_array));
+ _M_thread_freelist = NULL;
}
}
};
============================
It seems to be on each thread-implementation to handle deleted keys and it is
well handled on pthread.
Laurent.