monocle-micropython icon indicating copy to clipboard operation
monocle-micropython copied to clipboard

Restarting (Ctrl+D) does not reset module's variables

Open josuah opened this issue 1 year ago • 0 comments

All the custom C code of the modules would need to reset the variables to zero.

This is done by C at startup, but when rebooting MicroPython, the global variables contained within the modules might have invalid code.

For instance, callbacks might be pointing at invalid memory, or worse: working code that is not referred by malloc and might be overwritten at any time.

One possible solution is to use MicroPython __init__, a single struct globals for all global variables, and inside __init__, memset the struct globals to 0 (or default values).

josuah avatar Oct 18 '23 13:10 josuah