Skip to content

Lack of proper cleanup in ArduinoOTA class (missing end() in ~ArduinoOTA) #9228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cziter15 opened this issue Feb 4, 2025 · 2 comments
Open

Comments

@cziter15
Copy link
Contributor

cziter15 commented Feb 4, 2025

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.

ArduinoOTAClass::~ArduinoOTAClass(){

Workaround
Explicitly invoke the end() method in the code that owns ArduinoOTA code before the object is destroyed.

@mcspr
Copy link
Collaborator

mcspr commented Feb 4, 2025

Does it actually crash for ESP8266? Guru meditation Error: ... is ESP32-specific crash report format

Not sure I got the reasoning, though. ArduinoOTA constructor does not need MDNS, only ::begin() does.
It calls MDNS.start(_hostname) and MDNS.enableArduino(), MDNS.end() closes everything related to MDNS for everyone else.

MDNS.removeService("arduino", "tcp", PORT); // or MDNS.disableArduino();

Might be more appropriate here, replacing current MDNS.end() in the code?
(should we want to continue use global objects at all here)

@cziter15
Copy link
Contributor Author

cziter15 commented Feb 4, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants