Closed mrengineer7777 closed 1 year ago
@PilnyTomas Can you please check this issue? Thanks
I've been thinking about this. The macro reason2str
could cause a crash if the index passed doesn't match the expected range. The debug messages should be rewritten as a function to avoid this. Would you like me to submit a PR?
I'm experiencing a similar issue in my project.
ESP32-S2 on arduino-esp32 v2.0.6.
A user has reported it. It occurs every time he tries to use the device. But I haven't been able to reproduce it myself.
The ESP32 is waking up from deep sleep and trying to connect to a WPA3 network.
[ 1414][I][network.cpp:134] update(): [NET] connecting Wi-Fi (normal mode): SSID: ********
[ 1417][W][WiFiGeneric.cpp:955] _eventCallback(): Reason: 202 - AUTH_FAIL
E (1870) wifi:sta is connecting, return error
[ 2201][E][WiFiSTA.cpp:278] begin(): connect failed!
[ 6199][W][WiFiGeneric.cpp:955] _eventCallback(): Reason: 2 - AUTH_EXPIRE
[ 8055][I][network.cpp:154] update(): [NET] Wi-Fi connected (normal mode) in 5854 ms. Saving settings for quick mode...
[ 8056][I][network.cpp:155] update(): [NET] IP: 192.168.132.167
[ 8067][I][network.cpp:162] update(): [NET] SSID: ********, BSSID: xx:yy:zz:aa:bb:cc, CH: 6
[ 8073][W][WiFiGeneric.cpp:955] _eventCallback(): Reason: 8 - ASSOC_LEAVE
E (7878) wifi:Set status to INIT
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40007e40 PS : 0x00060d30 A0 : 0x8011ad4c A1 : 0x3ffe7250
A2 : 0x00000000 A3 : 0xfffffffc A4 : 0x000000ff A5 : 0x0000ff00
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x3ffe7452 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x50000000 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x40027945
Backtrace: 0x40007e3d:0x3ffe7250 0x4011ad49:0x3ffe7260 0x4011f942:0x3ffe7570 0x4011f97e:0x3ffe7600 0x4009f56d:0x3ffe7640 0x4009f62a:0x3ffe7680 0x400a8a2d:0x3ffe76d0 0x400a8e0d:0x3ffe77c0
Stack trace decoder (https://maximeborges.github.io/esp-stacktrace-decoder/) is reporting this:
0x4011ad49: _svfprintf_r at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/1/idf/crosstool-NG/.build/xtensa-esp32s2-elf/src/newlib/newlib/libc/stdio/vfprintf.c:1528
0x4011f942: _vsnprintf_r at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/1/idf/crosstool-NG/.build/xtensa-esp32s2-elf/src/newlib/newlib/libc/stdio/vsnprintf.c:70
0x4011f97e: vsnprintf at /Users/brnomac003/.gitlab-runner/builds/qR2TxTby/1/idf/crosstool-NG/.build/xtensa-esp32s2-elf/src/newlib/newlib/libc/stdio/vsnprintf.c:40
0x4009f56d: log_printfv at /Users/nejc/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-uart.c:543
0x4009f62a: log_printf at /Users/nejc/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-uart.c:576
0x400a8a2d: WiFiGenericClass::_eventCallback(arduino_event_t*) at /Users/nejc/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.cpp:955
0x400a8e0d: _arduino_event_task at /Users/nejc/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.cpp:305
Is there any progress on the issue?
@nplan Thanks for confirming it's not just me. Ironically it's the debug log message that causes the crash.
I'll submit a PR later to convert the reason2str macro into a function. That should resolve a potential crash due to bad index.
I have started working on this PR. Will submit next week.
Just had another crash on WiFiGeneric line 953, log_w("Reason: %u - %s", reason, reason2str(reason));
Time to finish the PR.
Completed by #8043
Board
ESP32-WROOM-32UE
Device Description
Custom hardware
Hardware Configuration
NA
Version
v2.0.7
IDE Name
PIO
Operating System
Win11
Flash frequency
40
PSRAM enabled
yes
Upload speed
460800
Description
Unexpected crash in WiFiGeneric.cpp with debug level 3 (info). I expect the WiFi module to print debug messages without crashing.
Crashed on WiFiGeneric
WIFI_REASON_UNSPECIFIED
line 953:log_w("Reason: %u - %s", reason, reason2str(reason));
.#define reason2str(r) ((r>176)?system_event_reasons[r-176]:system_event_reasons[r-1])
Not sure why it crashed. I think system_event_reasons[] is being indexed correctly.
Likely related to #7414. If we continue getting crashes on define
reason2str
then I recommend converting it to a function.This is how I print WiFi errors in my code:
Sketch
Debug Message
Other Steps to Reproduce
Have not reproduced the initial crash yet
I have checked existing issues, online documentation and the Troubleshooting Guide