You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
esp32/mpthreadport: Fix double delete of tasks on soft reset.
Python threads (created via the `_thread` module) are backed by a FreeRTOS
task. Managing the deletion of the task can be tricky, and there are
currently some bugs with this in the esp32 port.
The actual crash seen was in FreeRTOS' `uxListRemove()`, and that's because
of two calls to `vTaskDelete()` for the same task: one in
`freertos_entry()` when the task ran to completion, and the other in
`mp_thread_deinit()`. The latter tried to delete the task a second time
because it was still in the linked list, because `vTaskPreDeletionHook()`
had not yet been called. And the reason `vTaskPreDeletionHook()` was yet
to be called is because the FreeRTOS idle task was starved.
This commit fixes that.
There are three things done by this commit:
- remove the `vTaskPreDeletionHook`, it's not needed anymore because task
stack memory is allocated by the IDF, not on the MicroPython heap
- when a task finishes it now removes itself from the linked list, just
before it deletes itself
- on soft reset, all tasks are deleted and removed from the linked list in
one swoop (while the mutex is held)
Signed-off-by: Damien George <[email protected]>
0 commit comments