From 004c424b28df65ee8583bf58c5a14a6136f6b011 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Mon, 30 May 2022 23:14:29 +0300 Subject: Fix abort in Win32 DllMain if PARALLEL_MARK (a cherry-pick of commit 0c56f4381 from 'master') Also, enable GC_use_threads_discovery() on Windows even in case of PARALLEL_MARK. * tests/test.c [GC_WIN32_THREADS && !GC_PTHREADS && GC_DLL && !GC_NO_THREADS_DISCOVERY && !MSWINCE && !THREAD_LOCAL_ALLOC] (WinMain): Call GC_use_threads_discovery() regardless of PARALLEL_MARK. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY && PARALLEL_MARK] (GC_DllMain): Do not abort if DLL_PROCESS_ATTACH or DLL_THREAD_ATTACH (call GC_register_my_thread_inner instead). --- tests/test.c | 3 +-- win32_threads.c | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/test.c b/tests/test.c index a6085028..1d7983e9 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1815,8 +1815,7 @@ int APIENTRY WinMain(HINSTANCE instance GC_ATTR_UNUSED, # endif DWORD thread_id; # if defined(GC_DLL) && !defined(GC_NO_THREADS_DISCOVERY) \ - && !defined(MSWINCE) && !defined(THREAD_LOCAL_ALLOC) \ - && !defined(PARALLEL_MARK) + && !defined(MSWINCE) && !defined(THREAD_LOCAL_ALLOC) GC_use_threads_discovery(); /* Test with implicit thread registration if possible. */ GC_printf("Using DllMain to track threads\n"); diff --git a/win32_threads.c b/win32_threads.c index a5d5cb93..7181b703 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2915,9 +2915,6 @@ GC_INNER void GC_thr_init(void) /* This may run with the collector uninitialized. */ thread_id = GetCurrentThreadId(); if (parallel_initialized && GC_main_thread != thread_id) { -# ifdef PARALLEL_MARK - ABORT("Cannot initialize parallel marker from DllMain"); -# else struct GC_stack_base sb; /* Don't lock here. */ # ifdef GC_ASSERTIONS @@ -2926,7 +2923,6 @@ GC_INNER void GC_thr_init(void) GC_get_stack_base(&sb); GC_ASSERT(sb_result == GC_SUCCESS); GC_register_my_thread_inner(&sb, thread_id); -# endif } /* o.w. we already did it during GC_thr_init, called by GC_init */ break; -- cgit v1.2.1