From efc2732cdbd73fd4334ad7e012876c2755c94c51 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 31 Dec 2022 15:34:25 +0300 Subject: Check out-of-memory and set in_thread_creation inside GC_new_thread (refactoring) * pthread_support.c (GC_push_thread_structures): Add assertion that first_thread.tm.next and first_thread.status are null. * pthread_support.c (GC_new_thread): Rename id argument to self_id; add assertion that GC_in_thread_creation is off on entrance; set GC_in_thread_creation before GC_INTERNAL_MALLOC() first call and clear it after the second one; if crtn or result is null then ABORT instead of returning NULL. * pthread_support.c [!GC_DISABLE_INCREMENTAL] (GC_wait_for_gc_completion): Add assertion that GC_in_thread_creation is off before it is set. * pthread_support.c [!GC_WIN32_THREADS] (GC_register_my_thread_inner): Do not change GC_in_thread_creation value in this function directly; do not check the result of GC_new_thread(). * win32_threads.c (GC_register_my_thread_inner): Likewise. * win32_threads.c (GC_register_my_thread_inner): Remove assertion that the lock is held. --- win32_threads.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'win32_threads.c') diff --git a/win32_threads.c b/win32_threads.c index 46bc62e5..0d1ec5a6 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -241,12 +241,7 @@ GC_INNER GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb, } else # endif /* else */ /* Not using DllMain */ { - GC_ASSERT(I_HOLD_LOCK()); - GC_in_thread_creation = TRUE; /* OK to collect from unknown thread. */ me = GC_new_thread(self_id); - GC_in_thread_creation = FALSE; - if (NULL == me) - ABORT("Failed to allocate memory for thread registering"); } # ifdef GC_PTHREADS me -> pthread_id = pthread_self(); -- cgit v1.2.1