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

EDIT: Adding a STRING Properties without Setting it's value at Setup() Crashes the ESP32 #137

Open
jcherrabi opened this issue Jul 6, 2021 · 1 comment

Comments

@jcherrabi
Copy link

jcherrabi commented Jul 6, 2021

Hello there,
i added the following line to the AsyncProperty.ino example
ThingProperty text2("text2", "", STRING, nullptr, textChanged);

and in the setup() i added this:
textDisplay.addProperty(&text2);

Compile and run.. next add the thing using the + on the gateway interface, everything is fine so far now remove the added thing and try to add again and voila the ESP crashes and reboots... if i change the newly added property to BOOLEAN for example then it doesn't crash.

decoding the stack reveals this:
`PC: 0x4015691f: String::buffer() const at C:\Users\xxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h line 318
EXCVADDR: 0x00000008

Decoding stack results
0x4015691f: String::buffer() const at C:\Users\xxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h line 318
0x400d43da: ArduinoJson6180_D1::VariantData::storeString (ArduinoJson6180_D1::ArduinoStringAdapter, ArduinoJson6180_D1::MemoryPool*, ArduinoJson6180_D1::storage_policies::store_by_copy) at C:\Users\xxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32/WString.h line 230
0x400d443f: ArduinoJson6180_D1::Converter ::toJson(String const&, ArduinoJson6180_D1::VariantRef) at C:\Users\xxxx\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantData.hpp line 238
0x400d4a1d: ThingItem::serializeValue(ArduinoJson6180_D1::ObjectRef) at C:\Users\xxxx\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp line 88
0x400d7e63: WebThingAdapter::handleThingPropertyGet(AsyncWebServerRequest*, ThingItem*) at C:\Users\xxxx\Documents\Arduino\libraries\webthing-arduino/ESPWebThingAdapter.h line 403
0x401567c2: std::_Function_handler (WebThingAdapter*, std::_Placeholder1>, ThingProperty*)> >::_M_invoke(std::_Any_data const&, AsyncWebServerRequest*&&) at c:\users\xxxx\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0/functional line 600
0x400de8a1: AsyncCallbackWebHandler::handleRequest(AsyncWebServerRequest*) at c:\users\xxxx\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0/functional line 2271
0x400dc6ed: AsyncWebServerRequest::_parseLine() at C:\Users\xxxx\Documents\Arduino\libraries\ESPAsyncWebServer\src\WebRequest.cpp line 581
0x400dc7b1: AsyncWebServerRequest::_onData(void*, unsigned int) at C:\Users\xxxx\Documents\Arduino\libraries\ESPAsyncWebServer\src\WebRequest.cpp line 123
0x400dca01: std::_Function_handler >::_M_invoke(const std::_Any_data &, , , , ) at C:\Users\xxxx\Documents\Arduino\libraries\ESPAsyncWebServer\src\WebRequest.cpp line 76
0x400e06d1: AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at c:\users\xxxx\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0/functional line 2271
0x400e0751: AsyncClient::_s_recv(void*, tcp_pcb*, pbuf*, signed char) at C:\Users\xxxx\Documents\Arduino\libraries\AsyncTCP\src\AsyncTCP.cpp line 1191
0x400e0d4e: _async_service_task(void*) at C:\Users\xxxx\Documents\Arduino\libraries\AsyncTCP\src\AsyncTCP.cpp line 159
0x40089792: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143`

@jcherrabi
Copy link
Author

Hello again,
the problem was tracked to the following:

if you add a STRING property without setting its value in the Setup() it will crash.... as a workaround to prevent the crashing one MUST call the setValue() before addProperty in the setup() as follow:

ThingPropertyValue genericValue;

genericValue.string = "Some message";

textDisplay.setValue(genericValue);

textDisplay.addProperty(&text2);

basically this must be treated and fixed in the upcoming version to check if the value is null before trying to read it's value...

Cheers,
Jay

@jcherrabi jcherrabi changed the title Having Multiple String Properties Crashes the ESP32 EDIT: Adding a STRING Properties without Setting it's value at Setup() Crashes the ESP32 Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant