8000 stm32/extint: Handle VM abort in hard IRQ. · micropython/micropython@d5fa356 · GitHub
[go: up one dir, main page]

Skip to content

Commit d5fa356

Browse files
committed
stm32/extint: Handle VM abort in hard IRQ.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 4ea07c9 commit d5fa356

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ports/stm32/extint.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -712,16 +712,24 @@ void Handle_EXTI_Irq(uint32_t line) {
712712
// When executing code within a handler we must lock the GC to prevent
713713
// any memory allocations. We must also catch any exceptions.
714714
gc_lock();
715+
nlr_buf_t *nlr_abort_orig = nlr_get_abort();
715716
nlr_buf_t nlr;
716717
if (nlr_push(&nlr) == 0) {
718+
nlr_set_abort(&nlr);
717719
mp_call_function_1(*cb, pyb_extint_callback_arg[line]);
718720
nlr_pop();
719721
} else {
720-
// Uncaught exception; disable the callback so it doesn't run again.
721-
*cb = mp_const_none;
722-
extint_disable(line);
723-
mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in ExtInt interrupt handler line %u\n", (unsigned int)line);
724-
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
722+
nlr_set_abort(nlr_abort_orig);
723+
if (nlr.ret_val == NULL) {
724+
// Reschedule the abort.
725+
mp_sched_vm_abort();
726+
} else {
727+
// Uncaught exception; disable the callback so it doesn't run again.
728+
*cb = mp_const_none;
729+
extint_disable(line);
730+
mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in ExtInt interrupt handler line %u\n", (unsigned int)line);
731+
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
732+
}
725733
}
726734
gc_unlock();
727735
mp_sched_unlock();

0 commit comments

Comments
 (0)
0