-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
sntp module causes crash, apparently from the esp-idf framework itself (IDFGH-11754) #12854
Comments
esp_sntp_setoperatingmode() needs to be called before esp_sntp_init(). |
Yes, and I am respecting that in my code. But then some network instability occurs and it turns out the framework has a call to sntp_setoperatingmode hidden in some code of its own, and it creates havoc. |
@dannybackx Is it possible that you called if not, could you please provide more info about your startup code and SNTP initialization? some steps to reproduce? |
svn+ssh://[email protected]/p/esp32-s3-86-box-project-base/code/trunk/alarm/main/Network.cpp and ... App.cpp |
I believe it's possible to get into a scenario like you suggest from my code only. However, I don't believe that's what happened. If you look at the call stack on my original post, you'll see it's the framework that calls esp_netif_sntp_init again, causing a crash, not my code. |
A quick way to find out is to add this diff --git a/components/esp_netif/lwip/esp_netif_sntp.c b/components/esp_netif/lwip/esp_netif_sntp.c
@@ -90,6 +90,9 @@ void esp_netif_sntp_renew_servers(void *handler_args, esp_event_base_t base, int
esp_err_t esp_netif_sntp_init(const esp_sntp_config_t * config)
{
+ if (s_storage) {
+ return ESP_OK; // ESP_ERR_INVALID_STATE
+ }
esp_err_t ret = ESP_OK; and check if you're able to reproduce it.
This is telling me that
(where we ask the TCP/IP thread to run it in |
I think I found a way to remove the problem from my code (added a call to esp_netif_sntp_deinit() just after esp_sntp_stop() in the disconnect handler). But as you also said above
making the IDF code more robust is what I'm really asking for. |
At first sight what I wrote above (more consistency in my code) doesn't fix it. Didn't try the esp_netif_sntp_init patch you suggested yet.
Also I added a
but that message doesn't appear so this event didn't occur. |
I also have an application which crashes within Traceback:
Code:
|
@dannybackx I'm attaching the fix for your reference, but it's just about preventing from calling it more times. esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(..);
config.start = false; And then call @caco3 The traceback suggests that you're trying to initialize SNTP before LWIP was up and running. ( |
@david-cermak Thanks, we got it working now. |
I call "esp_netif_init();" before first sntp call. |
Answers checklist.
IDF version.
5.2 beta 1
Espressif SoC revision.
esp32s3
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
ZX3D95CE01S-TR-4848
Power Supply used.
External 5V
What is the expected behavior?
I admit I've been bitten by my own code calling an SNTP function that deliberately causes a crash, but now I see the framework itself can get there as well.
Either the sntp module shouldn't crash when it's not called in the right order (be nice about that), or the calling order from the framework should be fixed.
See logs included, network hiccup can crash sntp.
What is the actual behavior?
Steps to reproduce.
...
Debug Logs.
No response
More Information.
No response
The text was updated successfully, but these errors were encountered: