Skip to content

CORRUPT HEAP after opening the Websocket example #337

@jerre321

Description

@jerre321

When I open the Websocket example following error is shown in the Serial monitor and the ESP32 reboots:

CORRUPT HEAP: Bad tail at 0x3ffd94a8. Expected 0xbaad5678 got 0xbaad5600
assert` failed: multi_heap_free multi_heap_poisoning.c:259 (head != NULL)

I'm using an ESP32-WROOM-32 board and in platformio.ini I configured node32s.

The issue seems to be related to the "_webSocket.makeBuffer" function.

I have replace following code in WebSocketTxRx.h:

    size_t len = measureJson(jsonDocument);
    AsyncWebSocketMessageBuffer* buffer = WebSocketConnector<T>::_webSocket.makeBuffer(len);
    if (buffer) {
      serializeJson(jsonDocument, (char*)buffer->get(), len + 1);
      if (client) {
       client->text(buffer);
      } else {..........

with:

    String payloadStr;
    serializeJson(jsonDocument, payloadStr);
    if (client) {
      client->text(payloadStr); 
    } else {..........

Which fixes the crash and the example seems to work.

But I'm not an expert in this and want to understand what the real issue is and what the impact is of this change.
Because it looks like I'm the only one that is facing this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions