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

Skip to content

Commit b682eb2

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

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
@@ -708,16 +708,24 @@ void Handle_EXTI_Irq(uint32_t line) {
708708
// When executing code within a handler we must lock the GC to prevent
709709
// any memory allocations. We must also catch any exceptions.
710710
gc_lock();
711+
nlr_buf_t *nlr_abort_orig = nlr_get_abort();
711712
nlr_buf_t nlr;
712713
if (nlr_push(&nlr) == 0) {
714+
nlr_set_abort(&nlr);
713715
mp_call_function_1(*cb, pyb_extint_callback_arg[line]);
714716
nlr_pop();
715717
} else {
716-
// Uncaught exception; disable the callback so it doesn't run again.
717-
*cb = mp_const_none;
718-
extint_disable(line);
719-
mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in ExtInt interrupt handler line %u\n", (unsigned int)line);
720-
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
718+
nlr_set_abort(nlr_abort_orig);
719+
if (nlr.ret_val == NULL) {
720+
// Reschedule the abort.
721+
mp_sched_vm_abort();
722+
} else {
723+
// Uncaught exception; disable the callback so it doesn't run again.
724+
*cb = mp_const_none;
725+
extint_disable(line);
726+
mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in ExtInt interrupt handler line %u\n", (unsigned int)line);
727+
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
728+
}
721729
}
722730
gc_unlock();
723731
mp_sched_unlock();

0 commit comments

Comments
 (0)
0