8000 shared/runtime/pyexec: Set VM abort handler. · micropython/micropython@b94c65c · GitHub
[go: up one dir, main page]

Skip to content

Commit b94c65c

Browse files
committed
shared/runtime/pyexec: Set VM abort handler.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 0837708 commit b94c65c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

shared/runtime/pyexec.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
7979
nlr_buf_t nlr;
8080
nlr.ret_val = NULL;
8181
if (nlr_push(&nlr) == 0) {
82+
#if MICROPY_SCHED_VM_ABORT
83+
nlr_set_abort(&nlr);
84+
#endif
8285
mp_obj_t module_fun;
8386
#if MICROPY_MODULE_FROZEN_MPY
8487
if (exec_flags & EXEC_FLAG_SOURCE_IS_RAW_CODE) {
@@ -140,7 +143,12 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
140143
mp_hal_stdout_tx_strn("\x04", 1);
141144
}
142145

143-
// check for SystemExit
146+
#if MICROPY_SCHED_VM_ABORT
147+
if (nlr.ret_val == NULL) {
148+
// VM abort
149+
ret = PYEXEC_FORCED_EXIT;
150+
} else
151+
#endif
144152
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
145153
// at the moment, the value of SystemExit is unused
146154
ret = pyexec_system_exit;

0 commit comments

Comments
 (0)
0