Skip to content

Commit

Permalink
Merge pull request #5348 from tannewt/fix_s2_hang
Browse files Browse the repository at this point in the history
Clear the buffer byte between ATB and FTB
  • Loading branch information
dhalbert authored Sep 15, 2021
2 parents 59b1bed + e544909 commit ad663cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions py/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ void gc_init(void *start, void *end) {
assert(MP_STATE_MEM(gc_pool_start) >= MP_STATE_MEM(gc_finaliser_table_start) + gc_finaliser_table_byte_len);
#endif

// clear ATBs
memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len));
// Clear ATBs plus one more byte. The extra byte might be read when we read the final ATB and
// then try to count its tail. Clearing the byte ensures it is 0 and ends the chain. Without an
// FTB, it'll just clear the pool byte early.
memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len) + 1);

#if MICROPY_ENABLE_FINALISER
// clear FTBs
Expand Down

0 comments on commit ad663cb

Please sign in to comment.