Repository navigation
fix: avoid UiFtpServer mutex crash at boot - #448
Conversation
The UI polls isWiFiConnected() every second from boot on, even when FTP was never started. Its lock was the first use of the class mutex, and ESP-IDF allocates a std::mutex lazily on first lock. While WiFi was starting up this crashed the ThinkNode M9 in 3 of 4 boots (abort on system_error, interrupt WDT, or LoadProhibited inside the lock). isWiFiConnected() reads no class state, so drop the lock, matching RSSI(). Also make instance() creation thread-safe, since the WiFi event handler and the FTP server task call it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Singleton and WiFi status checks source/comms/UiFtpServer.cpp |
instance() uses a function-local static pointer. isWiFiConnected() checks WiFi status without acquiring the class mutex. |
Priority:
Estimated code review effort: 1 (Trivial) | ~5 minutes
Change: Bug fix
Suggested reviewers: mverch67
Merge Risk: 
Minimal · previous review 58191
-
No actionable issue is established with the FTP synchronization change; it is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Avoid taking a lock inside
isWiFiConnected()which can cause the device to crash while the wifi is still being started.Tested on Elecrow M9.
Summary by CodeRabbit