Repository navigation
Closed
Labels
Milestone
Description
What happened?
When using audio-reactive-led-strip to send LED data over UDP the ESP32 reboots after about 10sec of streaming with the following message:
Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled.
Core 1 register dump:
PC : 0x4010f783 PS : 0x00060c30 A0 : 0x8011450f A1 : 0x3ffb1e60
A2 : 0xffffffff A3 : 0x3ffb1e70 A4 : 0x3ffffffe A5 : 0x0004e18e
A6 : 0x3ffc7ecc A7 : 0x3ffb1e70 A8 : 0x8010f798 A9 : 0x3ffb1e40
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x00000003
EXCVADDR: 0x40000001 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffe
ELF file SHA256: 0000000000000000
Backtrace: 0x4010f780:0x3ffb1e60 0x4011450c:0x3ffb1f50 0x40114f1e:0x3ffb1f90 0x401338ad:0x3ffb1fb0 0x4008b89e:0x3ffb1fd0
#0 0x4010f780:0x3ffb1e60 in handleNotifications() at wled00/udp.cpp:530 (discriminator 1)
#1 0x4011450c:0x3ffb1f50 in WLED::loop() at wled00/wled.cpp:62
#2 0x40114f1e:0x3ffb1f90 in loop() at Z:/git/github/WLED/wled00/wled00.ino:20
#3 0x401338ad:0x3ffb1fb0 in loopTask(void*) at C:\Users\romai\.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:23
#4 0x4008b89e:0x3ffb1fd0 in vPortTaskWrapper at /home/cschwinne/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
Rebooting...
Running 75e857a with the following PIO config as suggested here #3637 (comment)
extends = env:esp32dev
monitor_filters = esp32_exception_decoder
build_flags = ${common.build_flags_esp32} ${common.debug_flags} -D WLED_RELEASE_NAME=ESP32_debug
To Reproduce Bug
Run visualisation.py from https://github.com/scottlawsonbc/audio-reactive-led-strip
Update config.py with the correct IP and UDP port.
Expected Behavior
Should run without crashing.
Install Method
Self-Compiled
What version of WLED?
WLED 0.14.1-b3 (build 2401060)
Which microcontroller/board are you seeing the problem on?
ESP32
Relevant log/trace output
No response
Anything else?
May be related to #3637
Code of Conduct
- I agree to follow this project's Code of Conduct
Reacted by Landcross
Activity
blazoncek commentedon Jan 11, 2024
Can you confirm (by adding DEBUG_PRINTs) that the line is 530? It is illogical as it is a
forloop statement.It would also be beneficial if you can capture a packet that causes the exception.
blazoncek commentedon Jan 11, 2024
And please provide WLED configuration (cfg.json).
blazoncek commentedon Jan 11, 2024
Tracing the changes, this code has not been changed in about 2 years. And only changed
uint16_ttosize_t.romain145 commentedon Jan 11, 2024
Line 530 before the for loop I added this to monitor the packetSize:
DEBUG_PRINTLN("WARLS packetSize: " + String(packetSize));This is the trace:
There is an underflow when packetSize == 2 line 530 in
for (size_t i = 2; i < packetSize -3; i += 4)Moreover I'm under the impression that
totalLen = strip.getLengthTotal();should terminate the loop if the number of packets received is too large?Here is the wled_cfg.json
softhack007 commentedon Jan 11, 2024
Indeed the part "packetsize -3" may underflow, as everything is computed as unsigned, and "2U - 3U = UINT32_MAX".
Please add the following right before the "for(" line:
if (packetSize > 2), and check if it works better.romain145 commentedon Jan 11, 2024
Yes I made the modification and the crash is gone.
I'll investigate audio-reactive-led-strip why small packets are sent.
Thanks
udp realtime - improve robustness against short packets (fix for #3672)
blazoncek commentedon Jan 11, 2024
The problem is
packetSize == 2as, if you look at source more closely, there isif (packetSize < 2) return;at the start of the WARLS code. This line should readif (packetSize < 5) return;instead.blazoncek commentedon Jan 11, 2024
There may be a bug in there as 2-byte packet only contains header and timeout seconds. No LED data.
softhack007 commentedon Jan 11, 2024
I was not sure if other formats (drgb) allow for 2-bytes packets. What is the minimal size for a "correct" UDP realtime packet?
We could then reject anything that is "too small" or "too large".
blazoncek commentedon Jan 11, 2024
Yes, you are correct. on more thorough inspection there are other possible valid packets <5.
blazoncek commentedon Jan 11, 2024
warls: 6 byte minimum
drgb: 5 byte minimum
drgbw: 6 byte minimum
dnrgbw: 7 byte minimum
that is assuming at least 1 LED data is present
blazoncek commentedon Jan 11, 2024
perhaps the easiest solution is to change
size_t iintoint i.Fix for #3672
softhack007 commentedon Jan 11, 2024
May work, but i'm not 100% sure how gcc will handle the resulting comparison between signed and unsigned.
Maybe its better to make assumptions explicit as you did in ea32c97.
Another question is, why did WLED receive short packages? Could it be fragmentation of large network packets? Or just a coding bug in the tool that sends the data?
Xploder commentedon Jan 15, 2024
Same crash with HyperHDR 20 as it also uses the reactive API now. Will try with final Release 14.1 now.
blazoncek commentedon Jan 15, 2024
The exact case from OP has been resolved in 0.14.1.
Xploder commentedon Jan 15, 2024
Can't confirm, same crashy behaviour with 0.14.1 using ESP32-Ethernet (on WT32-ETH01) and current HyperHDR master.
Rolling back to 0.14.0 fixes the issue.
blazoncek commentedon Jan 15, 2024
@Xploder please do as OP by providing relevant traces and open a new issue.
Fix for wled#3672
softhack007 commentedon Jan 15, 2024
@Xploder it might look similar, however the root cause of the specific crash that was reported by @romain145 is definitely fixed in 0.14.1.
Please open a new bug report ("New Issue") for the crash you see with 0.14.1.
It would be helpful if you also provide the following with your report:
udp realtime - improve robustness against short packets (fix for wled…
udp realtime - improve robustness against short packets (fix for wled…
Fix for wled#3672
udp realtime - improve robustness against short packets (fix for wled…