From 0a7eb0aa0bf7e7464e68ab9b6f4176771dcc3590 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Mon, 5 Dec 2022 18:59:31 -0500 Subject: nonmoving: Be more paranoid in segment tracking Previously we left various segment link pointers dangling. None of this wrong per se, but it did make it harder than necessary to debug. --- rts/sm/NonMoving.c | 3 +++ rts/sm/NonMovingMark.c | 2 ++ rts/sm/Storage.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'rts') diff --git a/rts/sm/NonMoving.c b/rts/sm/NonMoving.c index bbb499f4da..251151f287 100644 --- a/rts/sm/NonMoving.c +++ b/rts/sm/NonMoving.c @@ -850,6 +850,7 @@ static void nonmovingPrepareMark(void) // Save the filled segments for later processing during the concurrent // mark phase. + ASSERT(alloca->saved_filled == NULL); alloca->saved_filled = alloca->filled; alloca->filled = NULL; @@ -925,6 +926,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) ASSERT(n_nonmoving_marked_compact_blocks == 0); MarkQueue *mark_queue = stgMallocBytes(sizeof(MarkQueue), "mark queue"); + mark_queue->blocks = NULL; initMarkQueue(mark_queue); current_mark_queue = mark_queue; @@ -1088,6 +1090,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * seg->link = nonmovingHeap.sweep_list; nonmovingHeap.sweep_list = filled; } + nonmovingHeap.allocators[alloca_idx]->saved_filled = NULL; } // Mark Weak#s diff --git a/rts/sm/NonMovingMark.c b/rts/sm/NonMovingMark.c index 1b1e1c7b79..02cecd154f 100644 --- a/rts/sm/NonMovingMark.c +++ b/rts/sm/NonMovingMark.c @@ -271,6 +271,7 @@ static void nonmovingAddUpdRemSetBlocks_(MarkQueue *rset) bdescr *end = start; while (end->link != NULL) end = end->link; + rset->blocks = NULL; // add the blocks to the global remembered set ACQUIRE_LOCK(&upd_rem_set_lock); @@ -930,6 +931,7 @@ static MarkQueueEnt markQueuePop (MarkQueue *q) static void init_mark_queue_ (MarkQueue *queue) { bdescr *bd = allocGroup(MARK_QUEUE_BLOCKS); + ASSERT(queue->blocks == NULL); queue->blocks = bd; queue->top = (MarkQueueBlock *) bd->start; queue->top->head = 0; diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index d5b78ba12d..0309d3a565 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -324,7 +324,8 @@ void storageAddCapabilities (uint32_t from, uint32_t to) // Initialize NonmovingAllocators and UpdRemSets if (RtsFlags.GcFlags.useNonmoving) { nonmovingAddCapabilities(to); - for (i = from; i < to; ++i) { + for (i = from; i < to; i++) { + getCapability(i)->upd_rem_set.queue.blocks = NULL; nonmovingInitUpdRemSet(&getCapability(i)->upd_rem_set); } } -- cgit v1.2.1