rp2/mpthreadport: Fix memory corruption when thread is created in core1.
The stack (and arg) of core1 is itself a root pointer, not just the entries in it. Without this fix the GC could reclaim the entire stack (and argument object). Fixes issues #7124 and #7981.
This commit is contained in:
committed by
Damien George
parent
795370ca23
commit
2d47020e15
@@ -52,12 +52,12 @@ void mp_thread_deinit(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mp_thread_gc_others(void) {
|
void mp_thread_gc_others(void) {
|
||||||
if (get_core_num() == 0) {
|
if (core1_entry != NULL) {
|
||||||
// GC running on core0, trace core1's stack, if it's running.
|
// Collect core1's stack if it is active.
|
||||||
if (core1_entry != NULL) {
|
gc_collect_root((void **)&core1_stack, 1);
|
||||||
gc_collect_root((void **)core1_stack, core1_stack_num_words);
|
gc_collect_root((void **)&core1_arg, 1);
|
||||||
}
|
}
|
||||||
} else {
|
if (get_core_num() == 1) {
|
||||||
// GC running on core1, trace core0's stack.
|
// GC running on core1, trace core0's stack.
|
||||||
gc_collect_root((void **)&__StackBottom, (&__StackTop - &__StackBottom) / sizeof(uintptr_t));
|
gc_collect_root((void **)&__StackBottom, (&__StackTop - &__StackBottom) / sizeof(uintptr_t));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user