summaryrefslogtreecommitdiff
path: root/win32_threads.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-05-25 09:36:01 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-05-25 18:51:41 +0300
commite2a2e9aad923bb2288baf18aad8d38d925f56fa1 (patch)
tree396fd2b95cb20afb9b43daf4e5d61dadfa42bcd4 /win32_threads.c
parentac6d028f896c3bff209a7e84fc25157a8cd55d6e (diff)
downloadbdwgc-e2a2e9aad923bb2288baf18aad8d38d925f56fa1.tar.gz
Fix assertion violation in GC_allow_register_threads on Windows
(fix of commit ab93e03de) * pthread_support.c [GC_ASSERTIONS] (GC_allow_register_threads): Wrap GC_lookup_thread() call into LOCK/UNLOCK. * win32_threads.c [GC_ASSERTIONS] (GC_allow_register_threads): Wrap GC_lookup_thread_inner() call into LOCK/UNLOCK.
Diffstat (limited to 'win32_threads.c')
-rw-r--r--win32_threads.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/win32_threads.c b/win32_threads.c
index 972b02c1..cc0ccefc 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -769,8 +769,14 @@ STATIC void GC_delete_thread(DWORD id)
GC_API void GC_CALL GC_allow_register_threads(void)
{
- /* Check GC is initialized and the current thread is registered. */
- GC_ASSERT(GC_lookup_thread_inner(GetCurrentThreadId()) != 0);
+# ifdef GC_ASSERTIONS
+ DCL_LOCK_STATE;
+
+ /* Check GC is initialized and the current thread is registered. */
+ LOCK();
+ GC_ASSERT(GC_lookup_thread_inner(GetCurrentThreadId()) != 0);
+ UNLOCK();
+# endif
# if !defined(GC_ALWAYS_MULTITHREADED) && !defined(PARALLEL_MARK) \
&& !defined(GC_NO_THREADS_DISCOVERY)
/* GC_init() does not call GC_init_parallel() in this case. */