Skip to content

Commit 91a99fc

Browse files
jimmodpgeorge
authored andcommitted
tests/extmod/vfs_fat_finaliser.py: Ensure alloc at never-used GC blocks.
Prevents the finaliser from being missed if there's a dangling reference on the stack to one of the blocks for the files (that this test checks that they get finalised). See github.com/micropython/pull/7659#issuecomment-899479793 Signed-off-by: Jim Mussared <[email protected]>
1 parent 0c2cadf commit 91a99fc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/extmod/vfs_fat_finaliser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def ioctl(self, op, arg):
5656
# Here we test that the finaliser is actually called during a garbage collection.
5757
import gc
5858

59+
# Do a large number of single-block allocations to move the GC head forwards,
60+
# ensuring that the files are allocated from never-before-used blocks and
61+
# therefore couldn't possibly have any references to them left behind on
62+
# the stack.
63+
for i in range(1024):
64+
[]
65+
5966
N = 4
6067
for i in range(N):
6168
n = "x%d" % i

0 commit comments

Comments
 (0)