Repository navigation
In progress
In progress
Copy link
Labels
Milestone
Description
I've experienced random crashes on a -C5 when changing the Wi-Fi band from "both" to "5Gz".
WLED seems to reconnect (with the same network credentials), then shows a crash dump on serial monitor. After a reboot, the 5Ghz connection works and WLED continues to run without crashing again.
From the debug stack trace, it seems to be a problem related to mDNS - maybe we should stop mDNS before connecting to another Wi-Fi band.
Initial connect or forced reconnect (@ 223s).
WiFi: Default SSID (WLANxxxxx) used.
initConnection() called @ 223s.
WiFi disconnect.
WiFi-E: Disconnected! @ 223s
WiFi-E: STA Stopped
WiFi-E: Event 100
getWLEDHostname: 'wled-cf18c8'
WiFi mode_null: driver teardown / re-init.
WiFi-E: driver ready.
WiFi-E: STA Started
Access point disabled (init).
Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.
Core 0 register dump:
MEPC : 0x42093c1a RA : 0x420a07c4 SP : 0x40822870 GP : 0x40810604
TP : 0x40822910 T0 : 0x4209eb0a T1 : 0x40809b24 T2 : 0xffffffff
S0/FP : 0x00000001 S1 : 0x00000000 A0 : 0x00000000 A1 : 0x00000000
A2 : 0x00000001 A3 : 0x408228d0 A4 : 0x00000001 A5 : 0x00000000
A6 : 0x00000004 A7 : 0x4081c000 S2 : 0x408285ec S3 : 0x00000001
S4 : 0x4082b234 S5 : 0x00000000 S6 : 0x00000000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x4081c000 T4 : 0x00000001 T5 : 0x4081532c T6 : 0x00000006
MSTATUS : 0x00001881 MTVEC : 0x40800003 MCAUSE : 0x00000005 MTVAL : 0x000000e8
MHARTID : 0x00000000
rebooting...
ESP-ROM:esp32c5-eco2-20250121
Build:Jan 21 2025
rst:0xc (SW_CPU),boot:0x18 (SPI_FAST_FLASH_BOOT)
Core0 Saved PC:0x40808bbeStack Trace
| Nr | Address | Function | Location |
|---|---|---|---|
| 0 | 0x42093c1a | esp_netif_is_netif_up | ?? |
| 1 | 0x420a07c4 | join_group | mdns_networking_lwip.c.obj |
| 2 | 0x40810604 | __global_pointer$ | ?? |
| 3 | 0x4209eb0a | mdns_priv_get_esp_netif | ?? |
| 4 | 0x40809b24 | ledc_hal_set_hpoint | ?? |
| 5 | 0x40800003 | _vector_table | ?? |
| 6 | 0x4208d58a | sys_arch_mbox_fetch | ?? |
| 7 | 0x420a0986 | pcb_if_init_lwip | mdns_networking_lwip.c.obj |
| 8 | 0x4207d566 | tcpip_thread | tcpip.c.obj |
| 9 | 0x408107c4 | __global_pointer$ | ?? |
| 10 | 0x40810774 | __global_pointer$ | ?? |
| 11 | 0x40810774 | __global_pointer$ | ?? |
| 12 | 0x4085e6f0 | _stack_sentry | ?? |
Registers
MEPC 0x42093c1a esp_netif_is_netif_up at ??:?
RA 0x420a07c4 join_group at mdns_networking_lwip.c.obj:?
SP 0x40822870
GP 0x40810604
TP 0x40822910
T0 0x4209eb0a mdns_priv_get_esp_netif at ??:?
T1 0x40809b24 ledc_hal_set_hpoint at ??:?
T2 0xffffffff
Activity
[-]ESP32-C5 crsh when changing from 2.4Ghz to 5Ghz Wi-Fi (same network name)[/-][+]ESP32-C5 crash when changing from 2.4Ghz to 5Ghz Wi-Fi (same network name)[/+]Esmail-sarhadi commentedon Nov 2, 2026
The ordering theory fits the trace:
WiFi mode_null: driver teardown / re-initruns while mDNS is still up, and the mdns task holds a pointer to the netif that the teardown frees. On the C5 the mdns task and the wifi task share a core, so the free can land betweenselect()returning and the service task using the pointer - a load access fault at a low address, which is what the dump shows.The order that avoids it:
MDNS.end()in the ESP32 core callsmdns_free()and waits for the task to exit.mdns_free()on its own - which is what the disconnect path gives you - does not join the task, so the pointer can still be in use when the netif goes away.To confirm it is the ordering and not the band switch before changing anything: add a handler for
ARDUINO_EVENT_WIFI_STA_DISCONNECTEDthat callsMDNS.end()and nothing else, then repeat the 2.4 -> 5 GHz switch. If the crash disappears, the pointer lifetime is the cause and the fix is the explicit ordering above.For the general case, checking
MDNS.begin()'s return value after every reconnect turns a silent failure into a log line, which matters more than usual here because the crash happens after the reconnect has already been reported as successful.softhack007 commentedon Dec 2, 2026
There are some open ends listed in #5965
Stop mDNS before Wi-Fi teardown in initConnection() (#5945) (#5965)
[-]ESP32-C5 crash when changing from 2.4Ghz to 5Ghz Wi-Fi (same network name)[/-][+]random crashes (ESP32-C5) when changing from 2.4Ghz to 5Ghz Wi-Fi (same network name)[/+]Stop mDNS before Wi-Fi teardown in initConnection() (#5945) (#5965)
softhack007 commentedon Dec 2, 2026
@coderabbitai please summarize the remining open ends from #5964, including the assessment in #5945 (comment)
coderabbitai commentedon Dec 2, 2026
Analysis chain
Script executed:
Length of output: 60949
Script executed:
Length of output: 38342
Script executed:
Length of output: 15510
@softhack007The mDNS work appears to be in#5965, rather than#5964.#5965is merged;#5964concerns the Wi-Fi list and WPA-Enterprise settings.Remaining network open ends
Investigate the separate UDP crash. On a classic ESP32, reconnect tests found crashes in
notifier2Udp.parsePacket()→lwip_recvfrom→pbuf_freewith both the unmodified build and#5965. The cause is not established. Stopping UDP sockets before teardown is an experiment, not a confirmed fix.Coordinate UDP users and restart paths. Clearing connection flags can prevent later receive calls, but it does not close sockets or synchronize other tasks. A delay alone does not guarantee that other users have stopped. Compare the current behavior, flags-only, and synchronized stop-and-restart under UDP traffic. Check station reconnect, changed IP, AP fallback, UDP sync, RGB input and NTP. See the UDP assessment and follow-up.
Investigate the potential NTP race. The time-settings handler and the loop task can both call
ntpUdp.begin(). The flag does not serialize them. This race has not been reproduced or linked to the notifier crash. See the NTP analysis.Check other network services. E1.31 multicast, async Art-Net, MQTT, captive-portal DNS, and active HTTP/WebSocket clients need assessment across teardown and recovery. There is no established requirement to stop
AsyncWebServerbefore teardown. Shared AP and station services need particular care. See the service assessment.Investigate AP-mode UDP sync separately.
#5709may involve broadcast addressing rather than socket restart. A packet capture is needed to distinguish those possibilities.Complete validation. The reported S3 and classic ESP32 tests saw no recurrence of the mDNS crash with
#5965. A physical C5 band-switch test, mDNS answers after reconnect, and the enabledArduinoOTApath were still untested in the PR discussion. Repeat the S3 regression tests for any UDP changes.Broader assessment from
#5945The linked analysis proposes a stale-netif lifetime issue as the mDNS crash mechanism. It also raises possible follow-ups: check
MDNS.begin()and service-registration results, assess hostname sanitization and runtime name changes, review shared ArduinoOTA/mDNS ownership, and examine blockingMDNS.queryHost()calls.These are proposals to verify, not established causes of the reported crash. The accompanying patch was shared without build or applicability verification. The analysis also did not establish the exact resolved mDNS component version or legacy-build behavior.
For the actual
#5964, the remaining stated test gap is a real WPA-Enterprise login. The PR notes thatesp32devneedsCONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=yto compile that feature.Learnings used
You are interacting with an AI system.
Tycorc commentedon Dec 3, 2026
@softhack007 for the open end "stop UDP listeners before the Wi-Fi teardown": I tested both variants from #5965 (#5965 (comment)) on the classic ESP32 and the ESP32-S3 from my earlier test, on c70cbe8 (same tree as
mainafter the merge). Each reconnect is forced after a fresh boot by a/settings/wifisave that only changes the BSSID, with sync packets to port 65506 at 10 Hz.delay(250)stop()before the teardowninitInterfaces()->notifier2Udp.begin()->stop()->close()->netconn_drain->pbuf_free->esp_pbuf_free. So astop()after the teardown crashes too, it has to come beforeWiFi.disconnect().stop()before the teardown all 300 reconnects came back without a reboot, and UDP sync (21324, 65506) and raw RGB worked after each one. mDNS answered again in 10 of 10.ntpUdp.begin()from the time settings handler inset.cppintohandleNetworkTime(). NTP still syncs. I never got a crash from thatbegin()without the patch, so this part is not proven.Not tested: sending during the reconnect (sync send and node broadcast were off),
espalexaUdpandfftUdp(WiFiUDP too, not stopped by the block, not open here), the AsyncUDP receivers, ESP8266, C5, ArduinoOTA. 3 more patched attempts aborted on an HTTP timeout in my script, no crash.If u need more details or logs, let me know.
Patch and tests were AI-assisted.