From 3f5487ca902fb07fe8e334633a2fddfd6cf18762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 13 May 2020 15:57:17 +0200 Subject: [PATCH] [python] Forbid inlining on gc_collect to avoid missing some roots --- python/port/port.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/port/port.cpp b/python/port/port.cpp index be16aece9..385367101 100644 --- a/python/port/port.cpp +++ b/python/port/port.cpp @@ -248,7 +248,10 @@ KDColor MicroPython::ColorParser::ParseColor(mp_obj_t input, ColorMode ColorMode mp_raise_TypeError("Color couldn't be parsed"); } -void gc_collect(void) { +/* Forbid inlining to ensure regs to be at the top of the stack. Otherwise, + * LTO inlining can make regs lower on the stack than some just-allocated + * pointers. */ +__attribute__((noinline)) void gc_collect(void) { void * python_stack_top = MP_STATE_THREAD(stack_top); assert(python_stack_top != NULL);