cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_remove_handle closes easy handle, causes crash

From: Hauke Duden <h.ns.duden_at_gmx.net>
Date: Thu, 25 Mar 2010 16:20:43 +0100

On 24 Mar 2010, at 14:42, Hauke Duden wrote:

> On 23 Mar 2010, at 13:10, Daniel Stenberg wrote:
>
>> On Tue, 23 Mar 2010, Daniel Stenberg wrote:
>>
>>>> I have attached my test program. I don't know of any public FTP
>>>> servers, but I have tested it with 3 different ones and the
>>>> server does not seem to matter. Simply change the code of the
>>>> function initEasyRequest and enter the login details of any FTP
>>>> server and it should work (or rather, crash).
>>>
>>> Update: I can repeat the problem based on your example app, thanks
>>> a lot. I'm working on trying to understand it properly to make the
>>> accurate fix. Stay tuned!
>>
>> Here's my suggested fix that makes the test program run fine for me
>> (and all test cases too). I intend to commit and push to the git
>> repo within shortly.
>
>
> I have tested the fix in our main application. It seems to all work
> fine now. Thank you very much!

It seems that I have spoken too soon. The crash is gone, but we now
have a CURL easy handle leak in the main application. I suspect that
this is related to the connection sharing that used to cause the crash.

What I know about this problem:

1) the handle IS closed in our code with curl_easy_cleanup
2) the handle was attached to a multi handle at some point, but has
been removed before that one was closed.
3) the multi handle is already closed when the easy handle is closed
4) it seems that the handle was marked as a shared connection at some
point, but I was unable to verify this 100%.
5) don't know if this is related to the problem, but apparently a
"disconnect" FTP request is made when the connection is finally closed

I was unable to reproduce this in a simple environment. Our
application performs a bunch of FTP requests asynchronously and the
timing is not always the same. Up to now I was unable to determine
when a handle is leaked. It happens every time, but it is not always
the same request.

Can you give me some guidance as to how the connection sharing
algorithm works? This might help me to nail down the problem.

I.e. when exactly is a handle kept alive even though it is closed?
Should this happen even if the handle is not attached to a multi
handle anymore (but used to be)? When exactly is a connection marked
as "shared"?

Maybe this information will help me to recreate the problem in a
simpler setting.

Thanks,

Hauke

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-25