Repository navigation
Conversation
Run heap finalisers in reverse order during VM shutdown so VFS file handles are closed before their block devices and buses. Add a manual SD-card soft-reload regression test. Fixes adafruit#11562 Signed-off-by: Shantanu <i.shantanu2807@gmail.com>
There was a problem hiding this comment.
EDIT: my previous comment wasn't quite right, but the principle stands.
The finaliser table is a bitmap indexed by heap block. So the reverse sweep only works if the SDCardobject is lower in in the heap than the file object. But a gc could free blocks below the SDCard and then a file object could be lower in the heap.
Signed-off-by: Shantanu <i.shantanu2807@gmail.com>
|
Thanks for catching this. I removed the reverse bitmap sweep. Shutdown now has an explicit first pass for finalizer types that must close before their backing resources; FAT, LittleFS, POSIX file wrappers, and the FAT directory iterator finalizer are marked for that pass. Other finalizers stay on the normal teardown path. I also updated the manual regression test to allocate and free heap space below the SDCard before opening the file, so it exercises the lower-address reuse case you described. The earlier broad pre-reset finalizer pass caused Zephyr PWM trace failures; this narrower pass avoids those. The updated Build CI matrix has finished: all 690 jobs completed (689 passed; docs skipped). Unix, Zephyr simulation (including |
dhalbert
left a comment
There was a problem hiding this comment.
This problem has come up in other contexts, like #11108, and is a general problem that would be solved by a topological sort (#11108 (comment)), but it's not easy.
The MP_TYPE_FLAG_FINALISER_FIRST flag you propose is a manual way to solve the problem, and maybe it's good enough for single-level ordering. I'll discuss this with the other core developers - thanks.
|
Thanks for the context. I agree that |
Summary
Fixes #11562
Testing
native_sim.