diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-05-15 08:12:30 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-05-15 11:13:03 +0300 |
commit | 18e5b12da8d638a4d567c2f888201a4fc86c9c64 (patch) | |
tree | b6b02623537da8c41223e5838f37bf418f72990a | |
parent | cd465f79c52aa887d2b65a1b26447179def228b6 (diff) | |
download | bdwgc-18e5b12da8d638a4d567c2f888201a4fc86c9c64.tar.gz |
Clear GC_thread_key thread-local value on unregistering the thread
* pthread_support.c [THREAD_LOCAL_ALLOC]
(GC_unregister_my_thread_inner): Move assertion to
GC_destroy_thread_local().
* thread_local_alloc.c (GC_destroy_thread_local): Call GC_setspecific()
to clear thread-local value associated with GC_thread_key.
-rw-r--r-- | pthread_support.c | 1 | ||||
-rw-r--r-- | thread_local_alloc.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/pthread_support.c b/pthread_support.c index c52394aa..ae62cbac 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -2070,7 +2070,6 @@ STATIC void GC_unregister_my_thread_inner(GC_thread me) # endif GC_ASSERT(!KNOWN_FINISHED(me)); # if defined(THREAD_LOCAL_ALLOC) - GC_ASSERT(GC_getspecific(GC_thread_key) == &me->tlfs); GC_destroy_thread_local(&me->tlfs); # endif # ifdef NACL diff --git a/thread_local_alloc.c b/thread_local_alloc.c index b8b18c14..996034a4 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -131,6 +131,7 @@ GC_INNER void GC_destroy_thread_local(GC_tlfs p) int k; GC_ASSERT(I_HOLD_LOCK()); + GC_ASSERT(GC_getspecific(GC_thread_key) == p); /* We currently only do this from the thread itself. */ GC_STATIC_ASSERT(THREAD_FREELISTS_KINDS <= MAXOBJKINDS); for (k = 0; k < THREAD_FREELISTS_KINDS; ++k) { @@ -141,6 +142,8 @@ GC_INNER void GC_destroy_thread_local(GC_tlfs p) # ifdef GC_GCJ_SUPPORT return_freelists(p -> gcj_freelists, (void **)GC_gcjobjfreelist); # endif + /* Clear the pointer to tlfs. */ + (void)GC_setspecific(GC_thread_key, NULL); } STATIC void *GC_get_tlfs(void) |