summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-06-21 08:24:21 +0200
committerDamien George <damien@micropython.org>2025-07-06 00:05:47 +1000
commitf04475afd82537e830a09bc58a3d14f9fee4a767 (patch)
treea91fbc346ddf8e51391e58ed1240b5b5b3771f03 /py
parentff8c4e594375711297e1c6181dec483f1127f29e (diff)
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>
Diffstat (limited to 'py')
-rw-r--r--py/runtime.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/runtime.h b/py/runtime.h
index a93488e2c..f42039cab 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -169,6 +169,12 @@ static inline void mp_thread_init_state(mp_state_thread_t *ts, size_t stack_size
ts->nlr_jump_callback_top = NULL;
ts->mp_pending_exception = MP_OBJ_NULL;
+ #if MICROPY_PY_SYS_SETTRACE
+ ts->prof_trace_callback = MP_OBJ_NULL;
+ ts->prof_callback_is_executing = false;
+ ts->current_code_state = NULL;
+ #endif
+
// If locals/globals are not given, inherit from main thread
if (locals == NULL) {
locals = mp_state_ctx.thread.dict_locals;