-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Crash in serializeJson with Empty Values after Update (Arduino-ESP32 3.1.2) #10971
Comments
I also noticed this error. same with pioarduino 53.03.12. switched back to 3.1.1 (53.03.11) maybe same issue with tzapu/WiFiManager lib: empty WLAN config (start AP mode) ends up in a exception loop, when calling Exception: Core 1 register dump: Backtrace: 0x4008c1aa:0x3ffb20f0 0x4012c0e9:0x3ffb2100 0x40125072:0x3ffb2120 0x4012564d:0x3ffb2190 0x40109c80:0x3ffb2200 0x4012efdb:0x3ffb2270 0x400900c2:0x3ffb2290 sorry, cannot use exception decoder (debug flash size grows 139%). |
@TD-er PTAL. This is a consequence of your changes :) |
Yep, now that I see the crash (+ line nr), it is obvious why it crashes and is indeed due to my changes in this PR: It should not call String &String::operator=(const char *cstr) {
return copy(cstr, strlen(cstr));
} |
Could you test if this will fix it? |
i rechecked it,the proble solved! |
Just tried the fix. My code stopped crashing with the latest ArduinoJson library. |
same test result with tzapu/WiFiManager lib: no exceptions |
Board
Board: ESP32-S3
Device Description
Description:
After updating to Arduino-ESP32 3.1.2, we observed frequent crashes when using serializeJson with DynamicJsonDocument. The issue occurs specifically when handling empty or minimal JSON objects like {} or when the serialized String is empty (""). This behavior was not present in previous versions and might be related to recent changes in String behavior (String::move fix). The crash generates a Guru Meditation Error (LoadProhibited).
Example Code:
DynamicJsonDocument doc(2048);
doc["data"] = "{}";
String json;
serializeJson(doc, json); // Causes crash
We also experience similar crashes when serializing responses with minimal data (doc["data"] = {} or []), which should be valid JSON structures.
By switching to std::string for handling serialization, the crash is avoided. The modified code is shown below:
#include // Use std::string
DynamicJsonDocument doc(2048);
doc["data"] = "{}";
std::string jsonString;
serializeJson(doc, jsonString); // No crash
This might suggest an underlying issue with String conversion in the recent core update.
Environment:
Board: ESP32-S3
Core Version: Arduino-ESP32 3.1.2
ArduinoJson Version: 7.3.0
The issue seems closely related to serializeJson combined with String. Let me know if you need additional debug logs or a full backtrace.
Hardware Configuration
no
Version
v3.1.2
IDE Name
Arduino 2.3.4
Operating System
11
Flash frequency
40m
PSRAM enabled
no
Upload speed
115200
Description
no
Sketch
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: