From ba2c55a7e035a0874f7b1c578af7dc339e1a6127 Mon Sep 17 00:00:00 2001 From: Edd Barrett Date: Thu, 26 Mar 2026 09:28:00 +0000 Subject: [PATCH] Fix the micropython stack checker when building with yk. The C stack usage is computed by a function that finds the difference between two pointers. If that function gets a shadow stack, then we break it! This program would crash in a strange way, now it works: ```python for i in range(10000): if i == 300: 4 / 0 ``` --- py/cstack.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/cstack.c b/py/cstack.c index 7a578ee4fcf21..3f1f037f44468 100644 --- a/py/cstack.c +++ b/py/cstack.c @@ -55,6 +55,10 @@ void mp_cstack_init_with_sp_here(size_t stack_size) { #endif } +#ifdef USE_YK +// For this function to work properly, it must not have a shadow stack. +__attribute__((yk_outline)) +#endif mp_uint_t mp_cstack_usage(void) { // Assumes descending stack volatile int stack_dummy;