diff options
-rw-r--r-- | include/gc/gc.h | 2 | ||||
-rw-r--r-- | pthread_support.c | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/include/gc/gc.h b/include/gc/gc.h index bf64d2d9..c7640562 100644 --- a/include/gc/gc.h +++ b/include/gc/gc.h @@ -1626,6 +1626,8 @@ GC_API void GC_CALL GC_start_mark_threads(void); /* Return 1 (true) if the calling (current) thread is registered with */ /* the garbage collector, 0 otherwise. Acquires the allocator lock. */ + /* If the thread is finished (e.g. running in a destructor and not */ + /* registered manually again), it is considered as not registered. */ GC_API int GC_CALL GC_thread_is_registered(void); /* Notify the collector about the stack and the alt-stack of the */ 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 |