Skip to content

Commit 7559275

Browse files
committed
Merge branch 'bugfix/freertos_wcaps_coproc' into 'master'
fix(freertos): fix a bug in `prvTaskDeleteWithCaps` related to coprocessors Closes IDF-12202 See merge request espressif/esp-idf!36890
2 parents b5aef58 + c95a126 commit 7559275

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

components/freertos/esp_additions/idf_additions.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -100,15 +100,18 @@
100100

101101
configASSERT( eRunning != eTaskGetState( xTaskToDelete ) );
102102

103+
/* We can delete the task and free the memory buffers.
104+
* First, we must call `vTaskDelete` so that the port task delete callback is called.
105+
* On targets that have coprocessors, it may be possible that the stack pointer is modified (restored)
106+
* during this phase, hence, it must be done before getting the statuc buffers out of the task. */
107+
vTaskDelete( xTaskToDelete );
108+
109+
/* Free the memory buffers */
103110
xResult = xTaskGetStaticBuffers( xTaskToDelete, &puxStackBuffer, &pxTaskBuffer );
104111
configASSERT( xResult == pdTRUE );
105112
configASSERT( puxStackBuffer != NULL );
106113
configASSERT( pxTaskBuffer != NULL );
107114

108-
/* We can delete the task and free the memory buffers. */
109-
vTaskDelete( xTaskToDelete );
110-
111-
/* Free the memory buffers */
112115
heap_caps_free( puxStackBuffer );
113116
vPortFree( pxTaskBuffer );
114117
}

0 commit comments

Comments
 (0)