Pycardium Assertion after Reset

Reproduction

With the attached menu.py and a stub script.py, the following behavior can be observed:

  • Starting up, Pycardium loads the menu successfully
  • Selecting the script.py, it starts and after finishing, drops into the interpreter
  • Pressing the reset button now will trigger an assertion during load of menu.py:
assertion "VERIFY_PTR(ptr)" failed: file "../lib/micropython/micropython/py/gc.c", line 684, function: gc_realloc

This assertion is caused by a NULL dereference which leads to a field of struct scope_t to get the value 0x6b. The NULL pointer is created somewhere inside the MicroPython compiler for the field compiler_t.scope_cur.

Observations
  • It does not seem to be timing related: A delay in the reset stub or a delay at the start of Pycardium's main() does not change the behavior.
  • It does not seem to happen when running inside a script file before the reset; only when the REPL was running
  • It is not triggered when core 1 voluntarily jumps to the reset-stub using
    import os
    os.exit(0)