mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 00:51:42 +01:00 
			
		
		
		
	fix(freertos): fix a bug in prvTaskDeleteWithCaps related to coprocessors
				
					
				
			When a coprocessor is used, the stack pointer is altered. It must be restored before freeing the memory allocated to the task.
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
 | 
			
		||||
 * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 */
 | 
			
		||||
@@ -102,15 +102,18 @@ err:
 | 
			
		||||
 | 
			
		||||
        configASSERT( eRunning != eTaskGetState( xTaskToDelete ) );
 | 
			
		||||
 | 
			
		||||
        /* We can delete the task and free the memory buffers.
 | 
			
		||||
         * First, we must call `vTaskDelete` so that the port task delete callback is called.
 | 
			
		||||
         * On targets that have coprocessors, it may be possible that the stack pointer is modified (restored)
 | 
			
		||||
         * during this phase, hence, it must be done before getting the statuc buffers out of the task. */
 | 
			
		||||
        vTaskDelete( xTaskToDelete );
 | 
			
		||||
 | 
			
		||||
        /* Free the memory buffers */
 | 
			
		||||
        xResult = xTaskGetStaticBuffers( xTaskToDelete, &puxStackBuffer, &pxTaskBuffer );
 | 
			
		||||
        configASSERT( xResult == pdTRUE );
 | 
			
		||||
        configASSERT( puxStackBuffer != NULL );
 | 
			
		||||
        configASSERT( pxTaskBuffer != NULL );
 | 
			
		||||
 | 
			
		||||
        /* We can delete the task and free the memory buffers. */
 | 
			
		||||
        vTaskDelete( xTaskToDelete );
 | 
			
		||||
 | 
			
		||||
        /* Free the memory buffers */
 | 
			
		||||
        heap_caps_free( puxStackBuffer );
 | 
			
		||||
        vPortFree( pxTaskBuffer );
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user