-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
MODBUS TCP slave crash on start after stop (IDFGH-6568) #8211
Comments
Hi @oachkatzalschwoaf , Thank you for reporting this issue. The issue is supposed to be fixed in the commits: I will check this ASAP. Could you check these commits on your side? Thanks. |
The issue is confirmed. Please do the following to fix the issue:
The log after the fix is below: Please try the above and let me know the result. Thanks. |
now its working but somewehere might be a memory leak
|
I think what you are measuring here is the cost of heap fragmentation. UPDATE:
There are still some leaks in LWIP but after a couple init/destroy cycles the heap size gets stable (log below):
Please check this on your side. Thanks. |
Thanks @alisitsyn I've tested Heap Tracing feature for the first time last night - wasn't sure about the result, as i just got 7 entries, 6 of them: and a single xMBTCPPortInit
but each time 1 missed free with 120byte leaked
but after adding I also get the same result. With these changes the issue is fixed for me. |
Thank you for update. I guess we use different commits. The leak was in |
Thanks for reporting and sorry for slow turnaround, fix on master branch is available at dcaac79. |
Thanks for reporting, fixes on release/4.4 and release/4.3 are available, feel free to reopen if the issue still happens. Thanks. |
Hello @Alvin1Zhang, @alisitsyn and @oachkatzalschwoaf, i run into the exact same issue, but i am on release/4.4, where this issue normally shouldn't exist anymore?! Looking in the file system, my esp-idf contains the changes of commit dcaac79 linked by @Alvin1Zhang I am not sure if I have to open a new issue or if this issue gets reopened again. Steps to reproduce the issue:
|
Hello @dabbinavo, This issue has been corrected. I will check it soon. I will let you know when having some details. |
Hello @alisitsyn, ok, thanks for the hint! Now i found the other commit that fixes the issue on the release/v4.4 branch: Switching to the latest commit on release/v4.4 instead of using the tag v4.4 solves the issue. Didn't realize that the issue was fixed after the release of v4.4.. Seems that we have to wait for v4.4.1 to have the fix in an official release. |
Hello dabbinavo, I just recently checked this and found the fix in commit ba9c0c2 as well. The example works just fine on my side with release/v4.4 branch. The log:
This was planned to be merged in v4.4 but delays often happen... |
Thanks for reporting and sharing the feedback, will update once IDF v4.4.1 releases, thanks. |
I am still having this issue on my application. My application involves init() of Modbus TCP Slave after the Wifi IP Address is acquired. If I change the Wifi configuration, The logs on my end are while calling mbc_slave_destroy(). IDF version 5.2 |
Sorry for this mistake. There was the mistake when merging the MR. It is already fixed in the esp-modbus master with commit 2601e34e21238787d48b565867575fa825afad0a. Could you check it in your project and report before the component release? Let me know if you have any issues. Thanks. |
Thank you for pointing in the right direction. I have retested my project and it works correctly as expected. |
Thank you for update. My pleasure to help. The fix will be included into new component release. |
Environment
Problem Description
Crash/Guru Mediation when trying to initialize modbus-tcp after it got stopped.
Discovered on custom ESP32-S2, reproduced with example code on ESP32
Steps to reproduce
initialize modbus tcp as described in documentation: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/modbus.html?highlight=modbus#modbus-slave-api-overview
start/connect to wifi
mbc_slave_init_tcp()
mbc_slave_setup()
mbc_slave_set_descriptor()
mbc_slave_start()
mbc_slave_destroy()
goto steps 2-5
Code to reproduce this issue
Based on example mb_tcp_slave - changes:
Configured CONFIG_EXAMPLE_WIFI_SSID and CONFIG_EXAMPLE_WIFI_PASSWORD
modified app_main:
Debug Logs
The text was updated successfully, but these errors were encountered: