Skip to content

Commit f04475a

Browse files
jeplerdpgeorge
authored andcommitted
py/runtime: Initialize profile fields in mp_thread_init_state.
If the fields added for `MICROPY_PY_SYS_SETTRACE` are not initialized properly, their value in a thread is indeterminate. In particular, if the callback is not NULL, it will be invoked as a function. Signed-off-by: Jeff Epler <jepler@gmail.com>
1 parent ff8c4e5 commit f04475a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

py/runtime.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ static inline void mp_thread_init_state(mp_state_thread_t *ts, size_t stack_size
169169
ts->nlr_jump_callback_top = NULL;
170170
ts->mp_pending_exception = MP_OBJ_NULL;
171171

172+
#if MICROPY_PY_SYS_SETTRACE
173+
ts->prof_trace_callback = MP_OBJ_NULL;
174+
ts->prof_callback_is_executing = false;
175+
ts->current_code_state = NULL;
176+
#endif
177+
172178
// If locals/globals are not given, inherit from main thread
173179
if (locals == NULL) {
174180
locals = mp_state_ctx.thread.dict_locals;

0 commit comments

Comments
 (0)