Description
This is a bug that I originally found in our own commercial product running a fork of MicroPython, but I have since reproduced on the mainline STM32 port as well.
At the friendly REPL, if you enter an expression such as "a" * 10000
and then very quickly hit Ctrl-C, MicroPython will crash with "FATAL: uncaught exception <pointer>
", where <pointer>
corresponds to mp_state_ctx.vm.mp_kbd_exception
.
I am able to reproduce this with both the v1.10 and v1.11 branches, including the current master (154062d). For v1.11 reproduction, I am using an STM32F415ZG based dev board internal to our company (compiled on a branch whose only changes are board-specific, no core tweaks). My other reproduction is on our Silicon Labs EFM32 based product. The fact that I can reproduce on STM32 tells me the bug is not specific to our product.
I am not able to reproduce on v1.9, at least where I've tested (including a microbit).
From my own analysis of the "uncaught exception" message, I believe the cause of the crash is that the REPL runs parse_compile_execute
to execute the given expression, which sees the KeyboardInterrupt being raised, restores context, and re-raises -- but there's no surrounding nlr_push
at the REPL, so nlr_jump_fail
ends up being called.