-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
libssh2: Connection is not closed with CURLOPT_TIMEOUT #6990
Comments
libcurl and libssh2 versions ? |
Both current Git master. |
Also tested with current version of libssh2 1.9.0. I don't think this is a libssh2 issue. There were other (comparatively) minor memory leaks in 1.8.0 (~ 2-4KB in my tests) with libcurl 7.64.0, but those are gone since libssh2 1.9.0. With libcurl 7.74.0 or Git master of libcurl I have a leak of ~ 60KB now. |
... to avoid memory leaks! Reported-by: ccbenny on github Fixes #6990
Please try my first take in #6994. I can still get (other) leaks with libssh2 but I believe those might be libssh2's fault. I'll follow up on those separately. |
That works for my test case, thank you. I'm a bit worried that now we have no timeout at all for the handshake that seems to happen here. So if the connection breaks down during this last exchange, there is no parachute. Also, can you look at the issue with CURLOPT_DEBUGFUNCTION? Or should I open another bug report for that? |
Yeah not sure that the best action is here really. That's really a flaw in the libssh2 design as it doesn't allow us to just force-cleanup everything without doing anything over the socket (which that risk us getting EAGAIN back). We need to decide to either let libssh2 take its time, or shortcut that and risk a leak! I would presume that getting eagain should only be a temporary thing and if the connection gets dropped we shouldn't get again but another error that would move us on in the state machine. |
Please file a separate issue. |
Thank you for the help. |
This setup:
CURLOPT_TIMEOUT
.Problem:
We observe a serious memory leak. I have tracked it down to
libssh2_session_free
never being called.curl_easy_cleanup
.ibssh2.c:ssh_statemach_act
that handlesSSH_SFTP_SHUTDOWN
.libssh2_sftp_shutdown
and that givesEWOULDBLOCK
.ssh_statemach_act
is called fromssh_block_statemach
.ssh_block_statemach
the reaction to this is thatconnect.c:Curl_timeleft
gets called.Curl_timeleft
fails (returns a negative number), becausedata->set.timeout
is set to a timeout, butdata->progress.t_startop
is 0.ssh_block_statemach
returns and all the data allocated by libssh2 is abandoned.It seems that the CURL handle that is used in
Curl_conncache_close_all_connections
is not the same as the one used during the SFTP data transfer. This code probably does not expect that there is more network traffic during the disconnect handler that would need timeout handling. It is not quite clear where the correct value fordata->progress.t_startop
would come from.sftp_disconnect
could of course just set it to the current time, but that might not be entirely correct.A couple of additional thoughts:
CURLOPT_DEBUGFUNCTION
in the top-level handle is not set in the second CURL handle. This means that the call tofailf
inssh_block_statemach
does not show up anywhere.The text was updated successfully, but these errors were encountered: