From a0efe2d368456ec35c32d439d121cf8d7557bbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20de=20Giessen?= Date: Mon, 11 Mar 2024 17:32:13 +0100 Subject: [PATCH] esp32/main: Check if main GC heap allocation failed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the heap allocation fails we will crash if we continue, so at least we can show a clear error message so one can figure out memory allocation was the problem (instead of just seeing some arbitrary null pointer error later). Signed-off-by: Daniƫl van de Giessen --- ports/esp32/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/esp32/main.c b/ports/esp32/main.c index 6fb15d3cc8..62dd7ae3cc 100644 --- a/ports/esp32/main.c +++ b/ports/esp32/main.c @@ -116,6 +116,10 @@ void mp_task(void *pvParameter) { } void *mp_task_heap = MP_PLAT_ALLOC_HEAP(MICROPY_GC_INITIAL_HEAP_SIZE); + if (mp_task_heap == NULL) { + printf("mp_task_heap allocation failed!\n"); + esp_restart(); + } soft_reset: // initialise the stack pointer for the main thread