summaryrefslogtreecommitdiff
path: root/dbg_mlc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-04-01 09:05:05 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-04-01 09:05:05 +0300
commit5d6eca9e9df050f6295cdf33560f171388a66a60 (patch)
treea6e3b47d924269ccd5833bf3173e57b84dc5ce5f /dbg_mlc.c
parentdbcff3bb14748e6798700f094ccb2771b7160160 (diff)
downloadbdwgc-5d6eca9e9df050f6295cdf33560f171388a66a60.tar.gz
Ensure GC lock is held in add_leaked/smashed and check_heap_proc
(refactoring) * dbg_mlc.c [!SHORT_DBG_HDRS] (GC_add_smashed, GC_check_heap_proc): Assert that the GC lock is held (I_HOLD_LOCK). * reclaim.c (GC_add_leaked): Likewise. * dbg_mlc.c [!SHORT_DBG_HDRS] (GC_check_heap_proc): Remove "I hold lock" from comment not to duplicate the assertion.
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r--dbg_mlc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/dbg_mlc.c b/dbg_mlc.c
index 73ab496a..186039ce 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -473,7 +473,7 @@ STATIC void GC_debug_print_heap_obj_proc(ptr_t p)
STATIC void GC_print_all_smashed_proc (void);
#else
STATIC void GC_do_nothing(void) {}
-#endif
+#endif /* SHORT_DBG_HDRS */
GC_INNER void GC_start_debugging_inner(void)
{
@@ -941,6 +941,7 @@ STATIC unsigned GC_n_smashed = 0;
STATIC void GC_add_smashed(ptr_t smashed)
{
+ GC_ASSERT(I_HOLD_LOCK());
GC_ASSERT(GC_is_marked(GC_base(smashed)));
/* FIXME: Prevent adding an object while printing smashed list. */
GC_smashed[GC_n_smashed] = smashed;
@@ -997,10 +998,11 @@ STATIC void GC_check_heap_block(struct hblk *hbp, word dummy GC_ATTR_UNUSED)
}
}
-/* This assumes that all accessible objects are marked, and that */
-/* I hold the allocation lock. Normally called by collector. */
+/* This assumes that all accessible objects are marked. */
+/* Normally called by collector. */
STATIC void GC_check_heap_proc(void)
{
+ GC_ASSERT(I_HOLD_LOCK());
GC_STATIC_ASSERT((sizeof(oh) & (GRANULE_BYTES - 1)) == 0);
/* FIXME: Should we check for twice that alignment? */
GC_apply_to_all_blocks(GC_check_heap_block, 0);