summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-10-03 21:31:34 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-11-15 11:03:11 +0300
commit7f53221c72ef77209c9f4c89a38c1ba8ced78ddd (patch)
tree739efa0218a407000dba994523c17e0ea7b2a7e2
parent2ec7fc9f249bc03b1f911642f54b34588b2ea7c8 (diff)
downloadbdwgc-7f53221c72ef77209c9f4c89a38c1ba8ced78ddd.tar.gz
Fix missing lock while updating GC_in_thread_creation in GC_exit_check
(fix of commit 8e6460052) * misc.c [!DONT_USE_ATEXIT && THREADS] (GC_exit_check): Wrap each update of GC_in_thread_creation into LOCK/UNLOCK (but not GC_gcollect call); add comment.
-rw-r--r--misc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/misc.c b/misc.c
index 98a90dc3..901b693e 100644
--- a/misc.c
+++ b/misc.c
@@ -751,11 +751,19 @@ GC_API int GC_CALL GC_is_init_called(void)
{
if (GC_find_leak) {
# ifdef THREADS
+ DCL_LOCK_STATE;
+
+ /* GC_in_thread_creation should always be updated holding the */
+ /* lock even if we are about to exit. */
+ LOCK();
GC_in_thread_creation = TRUE; /* OK to collect from unknown thread. */
- GC_gcollect();
+ UNLOCK();
+# endif
+ GC_gcollect();
+# ifdef THREADS
+ LOCK();
GC_in_thread_creation = FALSE;
-# else
- GC_gcollect();
+ UNLOCK();
# endif
}
}