Lack of proper cleanup in ArduinoOTA class (missing end() in ~ArduinoOTA)
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Board
Not strictly related to hardware, so I'm skipping this section
### Description
I'm the author of ksIotFrameworkLib (iot library for arduino esp), working extensively with various ESP devices. Recently, I encountered a frustrating issue that led to crashes under specific conditions. The problem was challenging to pinpoint due to its random nature.
During the transition between the provisioning app and the regular operational app, I faced random exceptions:
`Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.`
My code is written in modern C++, utilizing `unique_ptr` as the standard practice. After investigating, I discovered that the root cause of the crash was linked to the mDNS service (an IDF component). Since I use ArduinoOTA without any global instances enabled, this was another area I needed to explore.
And - bingo!
It turns out that the ArduinoOTAClass does not correctly clean up mDNS in its destructor. It should be calling the end() method, but it doesn't. This issue also impacts the ESP32 framework.
https://github.com/esp8266/Arduino/blob/1a13ab95fb520e294ebffa4ece6b3a1466762604/libraries/ArduinoOTA/ArduinoOTA.cpp#L39
Workaround
Explicitly invoke the end() method in the code that owns ArduinoOTA code before the object is destroyed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.