Skip to content
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

Arduino v3.1.2 String crashes on serializeJson #2158

Open
Tobi177 opened this issue Feb 15, 2025 · 1 comment
Open

Arduino v3.1.2 String crashes on serializeJson #2158

Tobi177 opened this issue Feb 15, 2025 · 1 comment
Labels

Comments

@Tobi177
Copy link

Tobi177 commented Feb 15, 2025

Describe the bug
On the latest Arduino release v3.1.2 the function serializeJson does not work anymore and the app is crashing instantly. Within the Arduino release I see that some changes to the String objects were done: espressif/arduino-esp32#10938 Maybe, around this issue is the reason for the crashes, but that is just an assumption. Switching back to previous releases are working fine again. I rollback to Arduino v3.1.1 and the app is working fine again.

Environment
esp-idf v5.3 and Arduino v3.1.2 as a component
ArduinoJson v7.3.0
esp32, esp32c2

Reproduction

String getAvailableNetworks() {

  JsonDocument json_doc;
  JsonArray networks = json_doc.to<JsonArray>();

  int n = WiFi.scanNetworks(false, false);
  if (n) {
    for (int i = 0; i < n; ++i) {
      JsonObject networkObj = networks.add<JsonObject>();
      networkObj["ssid"] = WiFi.SSID(i);
      networkObj["rssi"] = WiFi.RSSI(i);
      networkObj["authmode"] = (WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? 0 : 1;
    }
  }

  String json_available_networks;
  serializeJson(json_doc, json_available_networks);  // CRASHES HERE

  return json_available_networks;

}

Only the String handling is affected! Once I use char arrays/pointers the serializeJson work fine on Arduino v3.1.2 as well. Only if strings are serialized the problem occurs. Please report back if any further information are needed. Thank you.

@Tobi177 Tobi177 added the bug label Feb 15, 2025
@bblanchon
Copy link
Owner

Hi @Tobi177,

Thank you for reporting this issue.

This issue was reported in espressif/arduino-esp32#10971 and fixed in espressif/arduino-esp32#10972.
Please confirm that this PR fixes the crash.

Best regards,
Benoit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants