diff --git a/python/port/port.cpp b/python/port/port.cpp index 302427e45..af3ea103c 100644 --- a/python/port/port.cpp +++ b/python/port/port.cpp @@ -138,13 +138,15 @@ void gc_collect(void) { * the case on a computer. We thus have to take the absolute value of the * addresses difference. */ size_t stackLength; + void ** scanStart; if ((uintptr_t)python_stack_top > (uintptr_t)®s) { stackLength = ((uintptr_t)python_stack_top - (uintptr_t)®s) / sizeof(uintptr_t); - gc_collect_root(regs_ptr, stackLength); + scanStart = regs_ptr; } else { stackLength = ((uintptr_t)(®s) - (uintptr_t)python_stack_top) / sizeof(uintptr_t); - gc_collect_root((void **)python_stack_top, stackLength); + scanStart = (void **)python_stack_top; } + gc_collect_root(scanStart, stackLength); gc_collect_end(); }