-
Notifications
You must be signed in to change notification settings - Fork 7.6k
CORRUPT HEAP assert failed: multi_heap_free when connecting to BLE Server #6961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@savejeff - This error maybe due to low Stack size of your Tasks. |
I know that it is hard to analyse this Problem. I have checked the total heap usage (around 50%) might this be a stack size problem in the Bluetooth task? Is there a way to check this? Is there a way to dump the state of all takes at the time of crash? FYI this is the current setting for the stack sized of the tasks. I'll try different settings
|
A few links that may help you in getting information about stack size versus stack consumption: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#_CPPv49vTaskListPc https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#_CPPv427uxTaskGetStackHighWaterMark12TaskHandle_t https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#_CPPv412vTaskGetInfo12TaskHandle_tP12TaskStatus_t10BaseType_t10eTaskState https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/mem_alloc.html |
Hi SuGlider, Thx for the links to analyze the stack. about the first link: i already tried vTaskList but i get a compilation error even when setting configUSE_TRACE_FACILITY=1 and configUSE_STATS_FORMATTING_FUNCTIONS =1. i get i have set both flags via buildflags. Might it be, that vTaskList is not included in the precompiled part? |
To answer some of your questions:
When using BLE, there is a memory region that's reserved for its operation, this region should not be part of the heap, otherwise the heap will be corrupted when the BLE uses its memory. Also in one of your screens there seems to be an allocation at |
Thx @Ouss4 Thanks for the clarification and insight. What i can rule out with high certainty is that is something like writing out of bound on arrays in my code. i also use malloc very carefully. I do a lot of print with float and String. so an unfortunate combination of multiple tasks try to print strings and floats into a format string the stack usage might increase to much. |
@savejeff do you still need help? |
ah sry. sadly vTaskList does not work even with the right flags enabled. seems like its not included in the precompiled code. would be helpful to have more insight into the tasks status. |
Board
ESP32-S3
Device Description
DevKitC-1, soldered and Breadboard using multiple Sensors over I2C and SPI, running on both cors with Multiple Tasks
Core0: running Task0 (higher prio) and Task2 (lower prio)
Core1: running Task1 (higher prio) and Task3 (lower prio)
Hardware Configuration
SARA R422M8N over Serial Port
SD Card over SPI
IMU over I2C
etc ...
Version
v2.0.3
IDE Name
PlatformIO
Operating System
Windows 10
Flash frequency
240Mhu
PSRAM enabled
yes
Upload speed
115200
Description
Since using the ESP32 S3 with Both cores with the Core version 2.0.0 i get heap corrupted errors on BLE connect
The Code runs fine until i connect through my smartphone to the BLE Server running on the ESP32-S3
this is what I'm getting

Debug Message
It seems to happen always when string is used. Might this be a not thread save malloc/free when a string object is created/destroyed. I had a similar issue on the RP2040 where malloc and free and some variants in newlib where not wrapped and thus crashes when both cores tried to print with a float
My Question
How can i interpret this error ? What could cause Heap Corruption?
what does multi_heap_free and multi_heap_poisoning mean?
What would be the best way to debug this?
I have checked:
There is enough Free ram. i use about 50% of the main RAM and around 20% of the PSRAM
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: