summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-04-28 23:03:32 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-30 16:56:44 -0400
commitb57b5b929bbb287b8392bfd015bf6adccdfac875 (patch)
treeb12b84018edd3cde7c65abbbc95a527b6e3bd9b6
parentab677cc856f7d479b69b8d73e54247fa053cf8d8 (diff)
downloadhaskell-b57b5b929bbb287b8392bfd015bf6adccdfac875.tar.gz
rts/m32: Fix assertion failure
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;