summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-04-28 23:03:32 -0400
committerBen Gamari <ben@smart-cactus.org>2022-04-28 23:03:32 -0400
commit37825ce283b6dbcb532f51fade090a69afc2d078 (patch)
treee785dc8d21fbb7ef1209c194e771123fee94f33f
parent22cf46980ad9b57eb428e7be045a1bc198b6380d (diff)
downloadhaskell-wip/m32-fixes.tar.gz
rts/m32: Fix assertion failurewip/m32-fixes
This fixes an assertion failure in the m32 allocator due to the imprecisely specified preconditions of `m32_allocator_push_filled_list`. Specifically, the caller must ensure that the page type is set to filled prior to calling `m32_allocator_push_filled_list`. While this issue did result in an assertion failure in the debug RTS, the issue is in fact benign.
-rw-r--r--rts/linker/M32Alloc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/rts/linker/M32Alloc.c b/rts/linker/M32Alloc.c
index b1138e032c..6ad316e164 100644
--- a/rts/linker/M32Alloc.c
+++ b/rts/linker/M32Alloc.c
@@ -405,6 +405,8 @@ void m32_allocator_free(m32_allocator *alloc)
static void
m32_allocator_push_filled_list(struct m32_page_t **head, struct m32_page_t *page)
{
+ ASSERT_PAGE_TYPE(page, FILLED_PAGE);
+ // N.B. it's the caller's responsibility to set the pagetype to FILLED_PAGE
m32_filled_page_set_next(page, *head);
*head = page;
}
@@ -535,6 +537,7 @@ m32_alloc(struct m32_allocator_t *alloc, size_t size, size_t alignment)
// If we haven't found an empty page, flush the most filled one
if (empty == -1) {
+ SET_PAGE_TYPE(alloc->pages[most_filled], FILLED_PAGE);
m32_allocator_push_filled_list(&alloc->unprotected_list, alloc->pages[most_filled]);
alloc->pages[most_filled] = NULL;
empty = most_filled;