summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-06-21 08:26:20 +0200
committerDamien George <damien@micropython.org>2025-07-06 00:06:14 +1000
commitf33f1aa9d36c4dd2de4e1209ed7a94f14505d981 (patch)
tree8667f74e1c586deeafc9f54e2412d4b4dd74d0d0
parentf04475afd82537e830a09bc58a3d14f9fee4a767 (diff)
unix/coverage: Initialize more code_state fields.
When `MICROPY_PY_SYS_SETTRACE` was enabled, a crash was seen in the qemu_mips build. It seems likely that this was due to these added fields not being initialized. Signed-off-by: Jeff Epler <jepler@gmail.com>
-rw-r--r--ports/unix/coverage.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c
index b041141f0..33e4208d9 100644
--- a/ports/unix/coverage.c
+++ b/ports/unix/coverage.c
@@ -582,12 +582,24 @@ static mp_obj_t extra_coverage(void) {
fun_bc.context = &context;
fun_bc.child_table = NULL;
fun_bc.bytecode = (const byte *)"\x01"; // just needed for n_state
+ #if MICROPY_PY_SYS_SETTRACE
+ struct _mp_raw_code_t rc = {};
+ fun_bc.rc = &rc;
+ #endif
mp_code_state_t *code_state = m_new_obj_var(mp_code_state_t, state, mp_obj_t, 1);
code_state->fun_bc = &fun_bc;
code_state->ip = (const byte *)"\x00"; // just needed for an invalid opcode
code_state->sp = &code_state->state[0];
code_state->exc_sp_idx = 0;
code_state->old_globals = NULL;
+ #if MICROPY_STACKLESS
+ code_state->prev = NULL;
+ #endif
+ #if MICROPY_PY_SYS_SETTRACE
+ code_state->prev_state = NULL;
+ code_state->frame = NULL;
+ #endif
+
mp_vm_return_kind_t ret = mp_execute_bytecode(code_state, MP_OBJ_NULL);
mp_printf(&mp_plat_print, "%d %d\n", ret, mp_obj_get_type(code_state->state[0]) == &mp_type_NotImplementedError);
}