Issue #171 (bdwgc).
GC_destroy_thread_local cannot be called from a thread other than
the current one.
* pthread_support.c [CAN_HANDLE_FORK && THREAD_LOCAL_ALLOC]
(GC_remove_all_threads_but_me): Do not call GC_destroy_thread_local;
add comment.
* win32_threads.c [CAN_HANDLE_FORK && THREAD_LOCAL_ALLOC]
(GC_remove_all_threads_but_me): Likewise.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_destroy_thread_local):
Update comment.
} else {
# ifdef THREAD_LOCAL_ALLOC
if (!(p -> flags & FINISHED)) {
- GC_destroy_thread_local(&(p->tlfs));
+ /* Cannot call GC_destroy_thread_local here. The free */
+ /* lists may be in an inconsistent state (as thread p may */
+ /* be updating one of the lists by GC_generic_malloc_many */
+ /* or GC_FAST_MALLOC_GRANS when fork is invoked). */
+ /* This should not be a problem because the lost elements */
+ /* of the free lists will be collected during GC. */
GC_remove_specific_after_fork(GC_thread_key, p -> id);
}
# endif
{
int k;
- /* We currently only do this from the thread itself or from */
- /* the fork handler for a child process. */
+ /* We currently only do this from the thread itself. */
GC_STATIC_ASSERT(THREAD_FREELISTS_KINDS <= MAXOBJKINDS);
for (k = 0; k < THREAD_FREELISTS_KINDS; ++k) {
if (k == (int)GC_n_kinds)
} else {
# ifdef THREAD_LOCAL_ALLOC
if ((p -> flags & FINISHED) == 0) {
- GC_destroy_thread_local(&p->tlfs);
+ /* Cannot call GC_destroy_thread_local here (see the */
+ /* corresponding comment in pthread_support.c). */
GC_remove_specific_after_fork(GC_thread_key, p -> pthread_id);
}
# endif