diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-12-19 08:10:03 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-12-19 08:10:03 +0300 |
commit | 8fdb2eefce858cbb560c08a0e2f6019d08efebb9 (patch) | |
tree | 94a4bcaece80f215c2b03be10ba0af4034d9dbeb /win32_threads.c | |
parent | a9c05c0311b76b9766dc46caa9e8036f5085b129 (diff) | |
download | bdwgc-8fdb2eefce858cbb560c08a0e2f6019d08efebb9.tar.gz |
Fix double call of unregister_my_thread if thread registered by DllMain
This, at least, avoids "Removing nonexistent thread" warning
if GC_ExitThread or GC_endthreadex is called by client and
DllMain-based thread registration is on.
* win32_threads.c (GC_win32_start_inner): Add assertion that
GC_win32_dll_threads is off.
* win32_threads.c (GC_ExitThread): Do not call GC_unregister_my_thread
if GC_win32_dll_threads (because the thread is to be unregistered by
DllMain).
* win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT]
(GC_endthreadex): Likewise.
Diffstat (limited to 'win32_threads.c')
-rw-r--r-- | win32_threads.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/win32_threads.c b/win32_threads.c index 7081055c..406d3d89 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -1346,6 +1346,7 @@ STATIC void *GC_CALLBACK GC_win32_start_inner(struct GC_stack_base *sb, ((struct win32_start_info *)arg) -> start_routine; LPVOID start_arg = ((struct win32_start_info *)arg) -> arg; + GC_ASSERT(!GC_win32_dll_threads); GC_register_my_thread(sb); /* This waits for an in-progress GC. */ # ifdef DEBUG_THREADS GC_log_printf("thread 0x%lx starting...\n", (long)GetCurrentThreadId()); @@ -1433,7 +1434,7 @@ GC_API HANDLE WINAPI GC_CreateThread( GC_API DECLSPEC_NORETURN void WINAPI GC_ExitThread(DWORD dwExitCode) { - (void)GC_unregister_my_thread(); + if (!GC_win32_dll_threads) (void)GC_unregister_my_thread(); ExitThread(dwExitCode); } @@ -1492,7 +1493,7 @@ GC_API DECLSPEC_NORETURN void WINAPI GC_ExitThread(DWORD dwExitCode) GC_API void GC_CALL GC_endthreadex(unsigned retval) { - (void)GC_unregister_my_thread(); + if (!GC_win32_dll_threads) (void)GC_unregister_my_thread(); _endthreadex(retval); } #endif /* !CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT */ |