8000 Merge pull request #5348 from tannewt/fix_s2_hang · unwiredben/circuitpython@ad663cb · GitHub
[go: up one dir, main page]

Skip to content

Commit ad663cb

Browse files
authored
Merge pull request adafruit#5348 from tannewt/fix_s2_hang
Clear the buffer byte between ATB and FTB
2 parents 59b1bed + e544909 commit ad663cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

py/gc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ void gc_init(void *start, void *end) {
150150
assert(MP_STATE_MEM(gc_pool_start) >= MP_STATE_MEM(gc_finaliser_table_start) + gc_finaliser_table_byte_len);
151151
#endif
152152

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

156158
#if MICROPY_ENABLE_FINALISER
157159
// clear FTBs

0 commit comments

Comments
 (0)
0