From 27563936ed8aa7fb2c261a50434a54f5414ee1a1 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Sun, 15 Aug 2021 11:11:11 +0530 Subject: [PATCH] fix crash on raise of reload exception --- py/mpstate.h | 2 ++ py/runtime.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/py/mpstate.h b/py/mpstate.h index 9f7d72a686..38f1f5188d 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -146,6 +146,8 @@ typedef struct _mp_state_vm_t { // exception object of type ReloadException mp_obj_exception_t mp_reload_exception; + // traceback object to store traceback + mp_obj_traceback_t mp_reload_traceback; // dictionary with loaded modules (may be exposed as sys.modules) mp_obj_dict_t mp_loaded_modules_dict; diff --git a/py/runtime.c b/py/runtime.c index 4d4fc3592b..55f26021ab 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -86,7 +86,8 @@ void mp_init(void) { MP_STATE_VM(mp_reload_exception).base.type = &mp_type_ReloadException; MP_STATE_VM(mp_reload_exception).args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj; - MP_STATE_VM(mp_reload_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; + MP_STATE_VM(mp_reload_exception).traceback = &MP_STATE_VM(mp_reload_traceback); + *MP_STATE_VM(mp_reload_exception).traceback = mp_const_empty_traceback_obj; // call port specific initialization if any #ifdef MICROPY_PORT_INIT_FUNC