Skip to content

Commit f33f1aa

Browse files
jeplerdpgeorge
authored andcommitted
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>
1 parent f04475a commit f33f1aa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ports/unix/coverage.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,24 @@ static mp_obj_t extra_coverage(void) {
582582
fun_bc.context = &context;
583583
fun_bc.child_table = NULL;
584584
fun_bc.bytecode = (const byte *)"\x01"; // just needed for n_state
585+
#if MICROPY_PY_SYS_SETTRACE
586+
struct _mp_raw_code_t rc = {};
587+
fun_bc.rc = &rc;
588+
#endif
585589
mp_code_state_t *code_state = m_new_obj_var(mp_code_state_t, state, mp_obj_t, 1);
586590
code_state->fun_bc = &fun_bc;
587591
code_state->ip = (const byte *)"\x00"; // just needed for an invalid opcode
588592
code_state->sp = &code_state->state[0];
589593
code_state->exc_sp_idx = 0;
590594
code_state->old_globals = NULL;
595+
#if MICROPY_STACKLESS
596+
code_state->prev = NULL;
597+
#endif
598+
#if MICROPY_PY_SYS_SETTRACE
599+
code_state->prev_state = NULL;
600+
code_state->frame = NULL;
601+
#endif
602+
591603
mp_vm_return_kind_t ret = mp_execute_bytecode(code_state, MP_OBJ_NULL);
592604
mp_printf(&mp_plat_print, "%d %d\n", ret, mp_obj_get_type(code_state->state[0]) == &mp_type_NotImplementedError);
593605
}

0 commit comments

Comments
 (0)