From 37825ce283b6dbcb532f51fade090a69afc2d078 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 28 Apr 2022 23:03:32 -0400 Subject: 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. --- rts/linker/M32Alloc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'rts') 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; -- cgit v1.2.1