Skip to content

Commit 31e0b8c

Browse files
committed
esp32/mpthreadport: Don't explicitly free thread struct in TCB cleanup.
Because vPortCleanUpTCB runs on the FreeRTOS idle task and cannot execute any VM or runtime related code like freeing memory. Signed-off-by: Damien George <damien@micropython.org>
1 parent fd24e64 commit 31e0b8c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

ports/esp32/mpthreadport.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ void mp_thread_finish(void) {
166166
mp_thread_mutex_unlock(&thread_mutex);
167167
}
168168

169+
// This is called from the FreeRTOS idle task and is not within Python context,
170+
// so MP_STATE_THREAD is not valid and it does not have the GIL.
169171
void vPortCleanUpTCB(void *tcb) {
170172
if (thread == NULL) {
171173
// threading not yet initialised
@@ -182,8 +184,7 @@ void vPortCleanUpTCB(void *tcb) {
182184
// move the start pointer
183185
thread = th->next;
184186
}
185-
// explicitly release all its memory
186-
m_del(thread_t, th, 1);
187+
// The "th" memory will eventually be reclaimed by the GC.
187188
break;
188189
}
189190
}

0 commit comments

Comments
 (0)