You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extmod/zephyr_kernel: Fix GC canary corruption with protected pointer.
The thread list contained interior pointers (th at offset +8) rather
than the full mp_thread_protected_t allocation start. When GC scanned
these interior pointers, it marked the mp_thread_t structure but not
the preceding canary_before field at offset 0. This caused GC to
incorrectly treat the allocation as starting at offset 8, allowing
heap reuse to corrupt the canary during concurrent gc.collect().
Fix by adding protected back-pointer to mp_thread_t that references
the full mp_thread_protected_t allocation. GC now scans this pointer
in mp_thread_gc_others(), ensuring the entire structure including
canaries is marked and protected from collection.
Also initialize all mp_thread_t fields before adding to thread list,
and add threads to list immediately after allocation (before
k_thread_create) to prevent mid-initialization GC from collecting
the structure.
Tested: Concurrent gc.collect() from 3 threads completes without
canary corruption (previously failed consistently).
Signed-off-by: Andrew Leech <[email protected]>
0 commit comments