-
Notifications
You must be signed in to change notification settings - Fork 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
Socket closed but not freed in NanostackInterface.cpp? #3168
Comments
cc @SeppoTakalo @kjbracey-arm |
Some more details: An instantiated socket is freed in destructor.
A possible fix of the constructor:
I assume your test cases should perform more socket open close cycles. |
I've seen a similar report before - and don't believe I got an answer to this question. Do you have a build of Nanostack where SOCKETS_MAX has been increased? The adaptation layer is vulnerable to that being increased - it has its own local assumption that it is 16. You should make a corresponding change to NS_INTERFACE_SOCKETS_MAX there. Nanostack does cycle through its socket IDs generally - seeing it increment in successive open calls doesn't mean you have a leak. |
Hello Kevin, see my latest findings above. It seems we both were adding comments at the same time. |
Yes, that seems clear enough. The ID cycling has helpfully concealed that little bug. However it appears someone has already caught it on master - the fix has been applied in commit 51fd80b. |
Ok, thanks. |
In the \mbed-os\features\net\FEATURE_IPV6\nanostack-interface, in the source file NanostackInterface.cpp. It looks like NanostackSocket::close(), closes the socket but does not free it. Every reopen (NanostackSocket::open) by calling temp_socket = socket_open(proto, 0, socket_callback), the returned socket ID (temp_socket) is incremented. So after a number of open close cycles, the returned socket ID clips on the maximum of 15, resulting in a asserting NanostackInterface.cpp function bool NanostackSocket::open(void):
The issue is triggered when the LWM2M client cannot find a LWM2M server. See call stack:
The text was updated successfully, but these errors were encountered: