Skip to content

CORRUPT HEAP assert failed: multi_heap_free when connecting to BLE Server #6961

Closed
@savejeff

Description

@savejeff

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
image

image

image

Debug Message

CORRUPT HEAP: Bad tail at 0x3fcb728c. Expected 0xbaad5678 got 0xbaad5600

assert failed: multi_heap_free multi_heap_poisoning.c:253 (head != NULL)


Decoding stack results
0x403776b2: panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c line 402
0x4037eea1: esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c line 128
0x40384cbd: __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c line 85
0x40384917: multi_heap_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap_poisoning.c line 245
0x40377b49: heap_caps_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c line 340
0x40384ced: free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/heap.c line 39
0x4205193d: String::invalidate() at C:/Users/Save_/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.h line 329
0x4205194d: String::~String() at C:/Users/Save_/.platformio/packages/framework-arduinoespressif32/cores/esp32/WString.cpp line 141

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

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions