Skip to content

Commit fd49fcb

Browse files
committed
stm32/gccollect: Always use MP_STATE_THREAD(stack_top) to get stack top.
In a non-thread build, using &_ram_end as the top-of-stack is no longer correct because the stack is not always at the very top end of RAM. See eg 04c7cdb and 3786592. The correct value to use is &_estack, which is the value stored in MP_STATE_THREAD(stack_top), and using the same code for both thread and non-thread builds makes the code cleaner.
1 parent a73859d commit fd49fcb

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

ports/stm32/gccollect.c

-4
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ void gc_collect(void) {
4848
uintptr_t sp = gc_helper_get_regs_and_sp(regs);
4949

5050
// trace the stack, including the registers (since they live on the stack in this function)
51-
#if MICROPY_PY_THREAD
5251
gc_collect_root((void**)sp, ((uint32_t)MP_STATE_THREAD(stack_top) - sp) / sizeof(uint32_t));
53-
#else
54-
gc_collect_root((void**)sp, ((uint32_t)&_ram_end - sp) / sizeof(uint32_t));
55-
#endif
5652

5753
// trace root pointers from any threads
5854
#if MICROPY_PY_THREAD

0 commit comments

Comments
 (0)