Cookie parser leaks memory?
Date: Wed, 23 Jan 2008 16:49:37 +0300
I have libcurl 7.15.1 (win32)
When I enable parser:
if (curl_easy_setopt(_curl, CURLOPT_COOKIEFILE, "") != CURLE_OK)
throw connection_failed("Couldn't setupe cookie parser...");
I receive cookie, read them, and then dispose of them with:
if(curl_easy_setopt(_curl, CURLOPT_COOKIELIST, "ALL") != CURLE_OK)
throw connection_failed("Couldn't clear request cookie list...");
then I reuse the same curl handler, and again use cookie and then
dispose of them and reuse the handler again.
Everything is fine except that the memory floats out. To make leak
more perceptible I return a huge cookie (1024bytes) and it is plainly
visible how curl eats memory.
Looks like cookie parser is just eating memory on each pass if the
cookies are new. The bug is easily missed since:
* there is maximum cookie length and servers will not allow this bug
to reproduce if there is no cleanup ("ALL", "SESSION")
* you got to clear cookie list to see the leak
whatever is going on it is bad. I beg your pardon if it is me. I'm
just updating my library and I wanted to introduce this feature for
my users but memory consumption test suit is failing on this build.
I've started to dig and I sincerely am not so good in C. I just wanted
you to know that it looks like there is a leak is cookie parser.
The steps to reproduce are :
make a script that would give out a huge
Set-Cookie: ough=asdfasdfdasfasdsakdlfhasdlkfhasklf MULTIPLIED by 1000 \n
Then you would have to configure libcurl to parse cookie (in many ways, I found
3 that would lead to the same result).
And then you would have to call this script via HTTP and clear
cookie with curl_easy_setopt(_curl, CURLOPT_COOKIELIST, "ALL");
and reuse the same handler to call this script again and again.
And you will see how memory usage is growing.
Thanks for keeping cURL up, and sorry for taking your time especially if
this report will prove to be my bug after all.
-- Best regards, Igor mailto:lanthruster_at_gmail.comReceived on 2008-01-23