diff options
| author | Damien George <damien@micropython.org> | 2021-05-08 18:14:13 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-05-08 22:47:03 +1000 |
| commit | 31e0b8c71c6e9bed7388439e2441465c58311393 (patch) | |
| tree | e5bf486ac0c203aa253d142be85c1a19d308d080 | |
| parent | fd24e649fde26bcd484b30025527768d37f5c562 (diff) | |
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>
| -rw-r--r-- | ports/esp32/mpthreadport.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ports/esp32/mpthreadport.c b/ports/esp32/mpthreadport.c index 140a76464..bbfc53d3f 100644 --- a/ports/esp32/mpthreadport.c +++ b/ports/esp32/mpthreadport.c @@ -166,6 +166,8 @@ void mp_thread_finish(void) { mp_thread_mutex_unlock(&thread_mutex); } +// This is called from the FreeRTOS idle task and is not within Python context, +// so MP_STATE_THREAD is not valid and it does not have the GIL. void vPortCleanUpTCB(void *tcb) { if (thread == NULL) { // threading not yet initialised @@ -182,8 +184,7 @@ void vPortCleanUpTCB(void *tcb) { // move the start pointer thread = th->next; } - // explicitly release all its memory - m_del(thread_t, th, 1); + // The "th" memory will eventually be reclaimed by the GC. break; } } |
