incorrect implementation of pvPortMalloc by the heap_4.c of FreeRTOS #85
Labels
mw
Middleware-related issue or pull-request.
rtos
RTOS-related issue or pull-request
third party
Third party related issue. Out of the scope of STMicroelectronics.
wontfix
This will not be worked on
Projects
Describe the set-up
Describe the bug
The function pvPortMalloc() is used to allocate memory for the required size.
The parameter xWantedSize indicates the length of memory required. However, when the required memory block size is zero. The memory pointer variable pvReturn will keep as NULL. If the configuration configUSE_MALLOC_FAILED_HOOK is enabled, it will recognize the variable xWantedSize valued zero as an error and handle it with the function vApplicationMallocFailedHook() as shown in https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/5fb26de0194b4ebfd09b37128bf9f3ff6d34c1b7/portable/MemMang/heap_4.c#L253 (also
STM32CubeH7/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c
Line 249 in beced99
How To Reproduce
Import the Domenstration example ClockAndWeather of the board STM32H7B3I-DK.
Enable macro configUSE_MALLOC_FAILED_HOOK. This is default enabled when I try to debug the program.
Run the firmware with a default configuration to reproduce and it will loop infinitely.
This problem is caused by the incorrect implementation of the function pvPortMalloc() by heap_4.c of FreeRTOS. This bug is already reported to FreeRTOS as shown in [BUG] incorrect implementation of pvPortMalloc FreeRTOS/FreeRTOS-Kernel#204.
Additional context
To patch it, should return NULL or the next available heap address when the parameter xWantedSize is zero.
The text was updated successfully, but these errors were encountered: