fix(tcp): prevent select error watchdog loop (EPROT-79) - #183
Conversation
|
Hi @ zyk6271, Thanks for the PR proposal. Unfortunately, I don't have time to review and test the related cases for now. I will take a look once have time for this. Please consider to extend your PR with the logs of stress testing with fault injection. |
Release accepted sockets and address metadata on all failure paths, close stale slave clients after fatal network-stack errors, and keep the master node table intact for reconnects. Also fix sparse-node timeout scanning and avoid using negative socket descriptors as fd_set indexes.
|
Implemented the requested stress/fault-injection follow-up in commit Key results on ESP32-D0WD-V3 / ESP-IDF v6.0.2: No The follow-up also fixes the accepted-socket/address leak itself, preserves TCP master reconnect definitions during fatal-error recovery, and removes negative-fd |
Summary
fd_seterrnologging whenselect()repeatedly failsRoot cause
Two failure modes combined in the reported long-running failure:
accept()/select()returnedENOMEM, Wi-Fi allocation failed, and connectivity was lost.select()immediately on persistent errors. The high-prioritymb_drv_tcp_taskcould therefore starve CPU0's IDLE task and trigger the task watchdog.The previous code also copied the full read set into
exceptfds, including non-socket descriptors, and did not consume exceptional client conditions.Changes
accept()errno, avoidclose(-1), and handle address/strdup()failuresopen_setselect()failuresHardware validation
Target: ESP32-D0WD-V3, ESP-IDF v6.0.2, esp-modbus v2.1.3 component sources, Modbus TCP slave with five client slots.
A/B resource-pressure fault injection
The fault injector holds all five clients open, then repeatedly creates extra TCP connections.
Unpatched firmware:
Patched firmware, with the same temporary heap telemetry:
A fresh run after the final source-review fixes:
Additional fault injection/regression
During the patched test windows there was no
errno=12,wifi:mem fail,wifi:m f null, select busy loop, or task WDT. A singleerrno=113while Wi-Fi was physically unavailable was expected and recovery completed after reassociation.Build validation
0xfdb30; smallest app partition remained 32% freegit diff --checkpassed for all five changed library files