From 5a8c02852532169ad81a87b553dc5fb3142d9e61 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 10 Mar 2023 07:38:33 +0300 Subject: Fix GC_thread_is_registered for finished threads (fix of commit 83c1eecd0) A finished thread may still stay in GC_threads, but it is no longer considered during a garbage collection phase, thus GC_thread_is_registered() should return false in such a case. * include/gc/gc.h [GC_THREADS] (GC_thread_is_registered): Refine comment (describe the case when the thread is marked as finished). * pthread_support.c (GC_thread_is_registered): Define and set me local variable; return FALSE if KNOWN_FINISHED(me). --- pthread_support.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pthread_support.c') diff --git a/pthread_support.c b/pthread_support.c index 63daff2b..1bd48eab 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -856,7 +856,9 @@ STATIC GC_thread GC_self_thread(void) { GC_API int GC_CALL GC_thread_is_registered(void) { - return GC_self_thread() != NULL; + GC_thread me = GC_self_thread(); + + return me != NULL && !KNOWN_FINISHED(me); } #ifndef GC_WIN32_THREADS -- cgit v1.2.1