summaryrefslogtreecommitdiff
path: root/mark_rts.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-05-25 08:41:37 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-05-25 09:54:42 +0300
commitfaa3bafd2da2d814b6ee1e99e38c44f3a54eed10 (patch)
tree9d9d8785e811314b1e0f25fb9d60604e24155aad /mark_rts.c
parent218e2571035ac6cea9633f713b5a4137bc8f3372 (diff)
downloadbdwgc-faa3bafd2da2d814b6ee1e99e38c44f3a54eed10.tar.gz
Ensure GC is initialized when GC_push_all_stacks() is called
(refactoring) Also, remove an unnecessary lock in GC pthread_create (of pthread_support.c), and ensure that GC_thr_init() is called only once. * alloc.c (GC_try_to_collect_inner, GC_collect_a_little_inner, GC_stopped_mark, GC_collect_or_expand, GC_allocobj): Add assertion that GC is initialized. * finalize.c (GC_register_disappearing_link_inner, GC_register_finalizer_inner): Likewise. * mark.c (GC_clear_marks, GC_initiate_gc): Likewise. * mark_rts.c (GC_push_roots): Likewise. * alloc.c (GC_collect_a_little): Call GC_init if GC is not initialized. * alloc.c (GC_expand_hp): Move part of comment to gc.h. * include/gc/gc.h (GC_expand_hp): Reformat comment. * darwin_stop_world.c (GC_push_all_stacks): Replace GC_init() call with the assertion that GC_thr_initialized. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c (pthread_create): Likewise. * darwin_stop_world.c (GC_stop_world): Add assertion that GC_thr_initialized. * pthread_stop_world.c (GC_stop_world): Likewise. * win32_threads.c (GC_push_all_stacks): Likewise. * finalize.c (GC_register_finalizer_inner): Add assertion (after LOCK) that obj points to the base address of the object. * include/private/pthread_support.h (GC_thr_initialized): Declare only if GC_ASSERTIONS. * pthread_support.c (GC_thr_initialized): Define only if GC_ASSERTIONS. * win32_threads.c (GC_thr_initialized): Likewise. * pthread_support.c (GC_thr_init): Add assertion that GC_thr_initialized is not set on entry; set GC_thr_initialized only if GC_ASSERTIONS. * win32_threads.c (GC_thr_init): Likewise. * pthread_support.c (pthread_create): Remove LOCK/UNLOCK around setup of si. * win32_threads.c (GC_stop_world): Replace ABORT (about GC_thr_initialized) with the assertion. * win32_threads.c (GC_CreateThread): Add assertion that GC_thr_initialized after GC_init_parallel() call. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Remove comment duplicating that in GC_CreateThread. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise.
Diffstat (limited to 'mark_rts.c')
-rw-r--r--mark_rts.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mark_rts.c b/mark_rts.c
index ccc32e89..17e52491 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -886,6 +886,7 @@ GC_INNER void GC_push_roots(GC_bool all, ptr_t cold_gc_frame GC_ATTR_UNUSED)
unsigned kind;
GC_ASSERT(I_HOLD_LOCK());
+ GC_ASSERT(GC_is_initialized); /* needed for GC_push_all_stacks */
/* Next push static data. This must happen early on, since it is */
/* not robust against mark stack overflow. */