shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

Using platformIO esp8266 panics every few seconds and reboots. #108

Open bobcroft opened 1 year ago

bobcroft commented 1 year ago

My issue is identical to an earlier bug reported as 'Kernel panic' , following on from the excellent imformation in that post / reply I set up a basic test using only the following in the loop;

void loop() { TBMessage msg; if (myBot.getNewMessage(msg)) Serial.print("got message"); delay (500); } That little snippet is enough to crash the esp8266. Referring to the exception decode even the most basic library example crashes and in all cases there is a reference to the Wstring.h (Ah, the curse of the 'String' versus the 'C' string!) I have also seen exception 9 too.

Serial monitor output;

Starting TelegramBot...

testConnection OK After a few seconds the esp8266 crashes

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (3): epc1=0x4020b595 epc2=0x00000000 epc3=0x00000000 excvaddr=0x402544fe depc=0x00000000

LoadStoreError: Processor internal physical address or data error during load or store epc1=0x4020b595 in String::init() at C:\Users\Bob.platformio\packages\framework-arduinoespressif8266\cores\esp8266/WString.h:289 (inlined by) String::String(char const*) at C:\Users\Bob.platformio\packages\framework-arduinoespressif8266\cores\esp8266/WString.cpp:39 excvaddr=0x402544fe in pp_attach at ??:?

stack>>>

I am using the latest version of platformIO under VSC and all libraries are the latest versions.

Further to my earlier comments I installed the Arduino 2.0.3 IDE along with allowing all library and board updates. Initially before the library / board updates I did successfully compile the basic echo example and it ran without crashing BUT it didn't receive or send any messages to telegram. I am of the opinion that either the newer tool chains or library versions break the code resulting in a soft WDT reset. This occurs both under the Ardsuino and platformIO IDE's.

shurillu commented 1 year ago

Hello bobcroft,

the issue that you pointed out is due to a problem with the ArduinoJson v 6.20.0 library. I've done different tests with it, and actually the solution is to use the v6.19.4 of the ArtuinoJson library. Keep on mind that I have two version of the CTBot:

Hoping that helps, cheers.

Stefano

bobcroft commented 1 year ago

Hello Stefano,

Thanks you for your prompt reply. I wondered if the issue might be with ArduinoJson library as I recall from its last release notes it had some breaking issues. I am not very proficient with Github but I assume you mean the new V3.0.0 version is available on Github, I’ll take a look.

When I have needed help with ArduinoJson in the past I have emailed Benoit Blanchon, its author, and found him extremely helpful. Perhaps he could help with the issues you are seeing.

I’ll report back later.

Kind regards

Bob

From: Stefano Ledda @.> Sent: 09 January 2023 08:45 To: shurillu/CTBot @.> Cc: bobcroft @.>; Author @.> Subject: Re: [shurillu/CTBot] Using platformIO esp8266 panics every few seconds and reboots. (Issue #108)

Hello bobcroft,

the issue that you pointed out is due to a problem with the ArduinoJson v 6.20.0 library. I've done different tests with it, and actually the solution is to use the v6.19.4 of the ArtuinoJson library. Keep on mind that I have two version of the CTBot:

Hoping that helps, cheers.

Stefano

— Reply to this email directly, view it on GitHub https://github.com/shurillu/CTBot/issues/108#issuecomment-1375274959 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVDXISCJ7ZMNSGXXY4O62DWRPFZBANCNFSM6AAAAAATUTG3AQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AAVDXIVIQHVBT2TUJ23436TWRPFZBA5CNFSM6AAAAAATUTG3ASWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSR7ED46.gif Message ID: @. @.> >

bobcroft commented 1 year ago

Hi Stefano, I have done as you suggested and changed the ArduinoJson version to 6.19.4. I have tried that version along with CTBot v2.1.9 and v3.0.0 on both an ESP32 and a Wemos d1 mini. CTbot V3.0.0 on the ESP 32 compliles, loads and runs to Telegrambot connected OK but it doesn't seem to send or receive any bot messages, it just sits there. I am monitoring bot messgaes on Node-RED so I can check if they are sent and they are sen immediately. The bot also receives messages from NR too. I tried CTBot V3.0.0 on the Wemos D1 mini, it loads, runs to Telegramconnected OK, reboots a couple of times and then crashes. I have attached a txt file of the very long exception decode. I do hope you can shed some light on why the ESP8266 is crashing but equally important why the ESP32 doesn't receive bot messages. FWIW I have tried two ther libraries without much sucess either. CtBot V3 with AJson 6.19.4 decode.txt

shurillu commented 1 year ago

Hello Bob, I've just finished to do some tests. Here my "test rig":

Let me know and thank you for your feedback! Cheers,

Stefano

bobcroft commented 1 year ago

Hi Stefano,

Thank you again for your detailed reply. To the best of my knowledge I have only one CTbot library. I tried them with platformIO and when I changed the library version I deleted the PIO files and then recompiled my code, the print out as the code compiled indicated the correct library was loaded. I had a quick look at the compile print out and I think I am using different tool chain versions. At my first attempt I used Arduino 2.0.3 not 1.8.15. I think I have, inadvertently used too many different versions of the various software.

Under platformIO I have the latest available versions of all toolchains etc. loaded and that may be causing issues.

Unfortunately I won’t be able to get back to more testing for just over a week because I am away from the PC I use for coding. Once I am able to check code again I plan to replicate the set up you have on your “test rig”.

I was pleased to see you use Visual Micro with visual studio, I used to use that years ago and for reasons I can’t remember I went away from it. I am planning to try it again.

I’ll report back on what I find

Bob

From: Stefano Ledda @.> Sent: 11 January 2023 10:06 To: shurillu/CTBot @.> Cc: bobcroft @.>; Author @.> Subject: Re: [shurillu/CTBot] Using platformIO esp8266 panics every few seconds and reboots. (Issue #108)

Hello Bob, I've just finished to do some tests. Here my "test rig":

Let me know and thank you for your feedback! Cheers,

Stefano

— Reply to this email directly, view it on GitHub https://github.com/shurillu/CTBot/issues/108#issuecomment-1378508638 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVDXIT45P6GX4MWOP5SNBDWR2AYTANCNFSM6AAAAAATUTG3AQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AAVDXIU2FVISQCNUPAZQVZTWR2AYTA5CNFSM6AAAAAATUTG3ASWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSSFJPV4.gif Message ID: @. @.> >

stsdc commented 1 year ago

I'm using bblanchon/ArduinoJson@6.19.4 and shurillu/CTBot@^2.1.10 on ESP8266. I'm trying to run echoBot example and getting this stacktrace just after testConnection OK message.

0x40100301 in millis at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_wiring.cpp:188
0x401002e5 in millis at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_wiring.cpp:185
0x4020d88e in optimistic_yield at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_main.cpp:150 (discriminator 1)
0x40212174 in esp8266::polledTimeout::timeoutTemplate<false, esp8266::polledTimeout::YieldPolicy::DoNothing, esp8266::polledTimeout::TimePolicy::TimeUnit<esp8266::polledTimeout::TimePolicy::TimeSourceMillis, 1000ull> >::checkExpired(unsigned long) const at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/PolledTimeout.h:238
 (inlined by) esp8266::polledTimeout::timeoutTemplate<false, esp8266::polledTimeout::YieldPolicy::DoNothing, esp8266::polledTimeout::TimePolicy::TimeUnit<esp8266::polledTimeout::TimePolicy::TimeSourceMillis, 1000ull> >::expiredOneShot() const at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/PolledTimeout.h:263
 (inlined by) esp8266::polledTimeout::timeoutTemplate<false, esp8266::polledTimeout::YieldPolicy::DoNothing, esp8266::polledTimeout::TimePolicy::TimeUnit<esp8266::polledTimeout::TimePolicy::TimeSourceMillis, 1000ull> >::expired() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/PolledTimeout.h:163
 (inlined by) esp8266::polledTimeout::timeoutTemplate<false, esp8266::polledTimeout::YieldPolicy::DoNothing, esp8266::polledTimeout::TimePolicy::TimeUnit<esp8266::polledTimeout::TimePolicy::TimeSourceMillis, 1000ull> >::operator bool() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/PolledTimeout.h:169
 (inlined by) BearSSL::WiFiClientSecureCtx::_run_until(unsigned int, bool) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp:468
0x4022b2e2 in br_ssl_engine_hs_reset at /home/earle/src/esp-quick-toolchain/arduino/tools/sdk/ssl/bearssl/src/ssl/ssl_engine.c:1320
0x402122b4 in BearSSL::WiFiClientSecureCtx::_wait_for_handshake() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp:585
0x402125f9 in BearSSL::WiFiClientSecureCtx::_connectSSL(char const*) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp:1170
0x40224883 in ip_chksum_pseudo at /home/earle/src/esp-quick-toolchain/arduino/tools/sdk/lwip2/builder/lwip2-src/src/core/inet_chksum.c:395
0x4021fef2 in tcp_output at /home/earle/src/esp-quick-toolchain/arduino/tools/sdk/lwip2/builder/lwip2-src/src/core/tcp_out.c:1361
0x40105dad in ets_timer_arm_new at ??:?
0x4020df46 in __delay at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_wiring.cpp:54
0x402108d2 in ClientContext::connect(ip4_addr*, unsigned short) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/include/ClientContext.h:148
 (inlined by) WiFiClient::connect(IPAddress, unsigned short) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClient.cpp:162
0x40212788 in BearSSL::WiFiClientSecureCtx::connect(char const*, unsigned short) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp:232
0x40214f48 in std::_Function_base::~_Function_base() at ??:?
0x40214f48 in std::_Function_base::~_Function_base() at ??:?
0x402149ac in BearSSL::WiFiClientSecureCtx::connect(String const&, unsigned short) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp:236
0x4020b386 in BearSSL::WiFiClientSecure::connect(String const&, unsigned short) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h:244
 (inlined by) CTBotSecureConnection::send(String const&) at .pio/libdeps/nodemcuv2/CTBot/src/CTBotSecureConnection.cpp:73
0x401008c9 in umm_free_core at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:549
0x40100ce4 in realloc at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:1125
0x40100b30 in realloc at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:853
0x40214dac in std::_Function_base::~_Function_base() at ??:?
0x4020d028 in String::isSSO() const at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:262
 (inlined by) String::setLen(int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:267
 (inlined by) String::concat(char const*, unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:309
0x4020cde8 in String::move(String&) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:240
0x4020cde8 in String::move(String&) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:240
0x40201550 in String::~String() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:79
 (inlined by) CTBot::sendCommand(String const&, String const&) at .pio/libdeps/nodemcuv2/CTBot/src/CTBot.cpp:30
0x4020cd05 in String::copy(char const*, unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:226
0x4020a2cc in CTBot::getMe(TBUser&) at .pio/libdeps/nodemcuv2/CTBot/src/CTBot.cpp:119
0x40255c8f in pp_attach at ??:?
0x40255cde in pp_attach at ??:?
0x401001e8 in ets_post at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_main.cpp:181
0x40102138 in pp_post at ??:?
0x40254d9b in ppTxPkt at ??:?
0x4023ed9b in ieee80211_send_probereq at ??:?
0x40240bd3 in scan_remove_probe_ssid at ??:?
0x402407a4 in scan_start at ??:?
0x40242e08 in cnx_start_handoff_cb at ??:?
0x40105dad in ets_timer_arm_new at ??:?
0x401042c7 in lmacProcessTXStartData at ??:?
0x401042c4 in lmacProcessTXStartData at ??:?
0x4010322b in wDev_ProcessFiq at ??:?
0x40240794 in scan_start at ??:?
0x40240768 in scan_start at ??:?
0x40240733 in scan_start at ??:?
0x4010307c in wDev_ProcessFiq at ??:?
0x40242e08 in cnx_start_handoff_cb at ??:?
0x4020f22a in esp8266::polledTimeout::timeoutTemplate<true, esp8266::polledTimeout::YieldPolicy::DoNothing, esp8266::polledTimeout::TimePolicy::TimeUnit<esp8266::polledTimeout::TimePolicy::TimeSourceCycles, 1000ull> >::reset(unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/PolledTimeout.h:187
 (inlined by) esp8266::polledTimeout::timeoutTemplate<true, esp8266::polledTimeout::YieldPolicy::DoNothing, esp8266::polledTimeout::TimePolicy::TimeUnit<esp8266::polledTimeout::TimePolicy::TimeSourceCycles, 1000ull> >::timeoutTemplate(unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/PolledTimeout.h:154
 (inlined by) run_scheduled_recurrent_functions() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/Schedule.cpp:176
0x4020d7ec in esp_yield at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_main.cpp:123
0x40249a09 in cont_continue at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/cont.S:51
0x4020d028 in String::isSSO() const at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:262
 (inlined by) String::setLen(int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:267
 (inlined by) String::concat(char const*, unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:309
0x40100aed in malloc at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:821
0x40100b30 in realloc at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:853
0x401008c9 in umm_free_core at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:549
0x40100aed in malloc at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:821
0x40100b30 in realloc at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:853
0x4020cb98 in String::changeBuffer(unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:195 (discriminator 4)
0x4020cbc4 in String::changeBuffer(unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:202
0x401008c9 in umm_free_core at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:549
0x40100ab6 in free at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:595
0x4020ca0c in String::init() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:289
 (inlined by) String::invalidate() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:147
0x4020ba39 in String::~String() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.h:80
 (inlined by) CTBotWifiSetup::wifiConnect(String const&, String const&) at .pio/libdeps/nodemcuv2/CTBot/src/CTBotWifiSetup.cpp:88
0x40100b30 in realloc at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/umm_malloc/umm_malloc.cpp:853
0x4020cbc4 in String::changeBuffer(unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:202
0x4020b007 in CTBot::testConnection() at .pio/libdeps/nodemcuv2/CTBot/src/CTBot.cpp:105
0x4020cd05 in String::copy(char const*, unsigned int) at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/WString.cpp:226
0x40201840 in CTBot::setTelegramToken(String const&) at .pio/libdeps/nodemcuv2/CTBot/src/CTBot.cpp:101
0x402010f3 in setup at src/main.cpp:27
0x4020d8cf in loop_wrapper() at /home/stsdc/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_main.cpp:198
shurillu commented 1 year ago

Hello stsdc, have you tried the echobot sketch? If not, please try it. Another question: looking your message, I suppose you are using an ESP8266 board. Which version of the ESP8266 library/toolchain are you using?

Cheers