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-14 21:49:31 +0300
commitccecdaf04411b65f5badbeaae36f50c9c216d37b (patch)
tree47444c705cda656ee5a0723755f21ff574484066
parent6d38614d7130c736442a2a7c6a9fcf69480592f8 (diff)
downloadbdwgc-ccecdaf04411b65f5badbeaae36f50c9c216d37b.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 8b02f53e..b542819d 100644
--- a/misc.c
+++ b/misc.c
@@ -766,11 +766,19 @@ GC_API int GC_CALL GC_is_init_called(void)
{
if (GC_find_leak && !skip_gc_atexit) {
# 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
}
}