Skip to content

Result from serializeJson contains "Failed to release mutex!" #2167

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

Open
AcuarioCat opened this issue Apr 5, 2025 · 1 comment
Open

Result from serializeJson contains "Failed to release mutex!" #2167

AcuarioCat opened this issue Apr 5, 2025 · 1 comment
Labels
bug v7 ArduinoJson 7

Comments

@AcuarioCat
Copy link

ESP32 with 16Mb
ESP32 version 3.0.7
ArduinoJson version 7.3.0

I am creating a Json using JsonDoc that contains 5 JsonObjects.
I am then serializing the Json to a string to write it to an SD card.

Occasionally in the middle of my string I get bits of what looks like debug output as follows:

"E04":6185,"lse && "Failed to release mutex!"":657,"se && "Failed to release mutex!"":691,"E11":0

or

"engine":{"lse && "Failed to release mutex!"":268,"E11":0

It is inconsistent and only occurs occasionally but when it does it seems the only way to clear it is to write to the SD card before creating the next Json and serializing it.

  • I tried checking the string for the mutex text and not writing it if this was in the string but then every subsequent string contained the mutex message until I wrote the string to the SD card, then it was cleared.

A code snippet at the end of my Json creation is:
doc.shrinkToFit(); serializeJson(doc, jsonString); return jsonString;

It does not seem to be related to the size of the Json (I have variable lengths) and sometimes occurs several times in a row then nothing for 25+ Jsons.
My Jsons are mostly less than 400 characters.

When it occurs it is always in the 5th JsonObject.

@AcuarioCat AcuarioCat added the bug label Apr 5, 2025
@bblanchon
Copy link
Owner

Hi,

The error message most likely originates from pthread_mutex_destroy():
https://github.com/espressif/esp-idf/blob/v5.1.4/components/pthread/pthread.c#L590

ArduinoJson doesn't use mutex or any other synchronization method, so the problem comes from somewhere else.

Start by updating the Arduino core for ESP32, and see if it helps.

If it doesn't help, create an MCVE; it will help you isolate the cause of the issue.
Remember that the root cause can be an undefined behavior (such as a buffer overrun or a stack overflow) in another part of your program, so don't hesitate to comment out unrelated pieces of code.

Best regards,
Benoit

@bblanchon bblanchon added the v7 ArduinoJson 7 label Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v7 ArduinoJson 7
Projects
None yet
Development

No branches or pull requests

2 participants