Skip to content
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

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

Closed
cziter15 opened this issue Feb 4, 2025 · 2 comments · Fixed by #10932
Closed

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

cziter15 opened this issue Feb 4, 2025 · 2 comments · Fixed by #10932
Labels
Status: Awaiting triage Issue is waiting for triage

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 ESP8266 framework.

Workaround

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

@cziter15 cziter15 added the Status: Awaiting triage Issue is waiting for triage label Feb 4, 2025
@cziter15 cziter15 changed the title Lack of proper cleanup in ArduinoOTA class Lack of proper cleanup in ArduinoOTA class (missing end() in ~ArduinoOTA ) Feb 4, 2025
@me-no-dev
Copy link
Member

Nice catch! I guess we never noticed it, because globals are enabled in Arduino by default. Fix is coming

@cziter15
Copy link
Contributor Author

cziter15 commented Feb 4, 2025

It was really tricky (and my luck) to find the cause. Actually stacktrace was not pointing to the OTA at all.

Rather it was randomly crashing somewhere after device connected the network. The only thing I've noticed was the logline like "mdns service is already running" or something like this, but this unfortunatelly didn't get my attention earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants