Donate Share

curl and libcurl

Tracker: Bugs

5 Curl_dns_entry leaked on redirect + connect failure - ID: 2891591
Last Update: Comment added ( bagder )

How to repro:

1. Set up a first web server that redirects (307) to a http://server:port that's down
2. Have curl connect to the first web server using curl multi

After the curl_easy_cleanup call, there will be curl dns entries hanging around with in_use != 0.

Working on a patch...


Constantine Sapuntzakis ( csapuntz ) - 2009-11-04 00:56:20 UTC

5

Closed

Fixed

Daniel Stenberg

name resolving/DNS

bad behaviour

Public


Comments ( 6 )

Date: 2009-11-17 22:54:16 UTC
Sender: bagderProject AdminAccepting Donations

Thanks for the report, this problem is now fixed in CVS!


Date: 2009-11-15 01:36:02 UTC
Sender: csapuntz

This one fixes the leaks by setting conn->dns_entry early and cleaning it
up in Curl_disconnect.

Setting conn->dns_entry early means it doesn't have to be passed around
everywhere.

Passes all tests I could run (no libssh2) including #19


Date: 2009-11-14 08:45:30 UTC
Sender: bagderProject AdminAccepting Donations

When applied, test 19 fails with a memory leak (if configure --enable-debug
was used):

test 019...[attempt connect to non-listening socket]

** MEMORY FAILURE
Leak detected: memory still allocated: 60 bytes
At 836e2e4, there's 16 bytes.
allocated by curl_addrinfo.c:156
At 836e2b4, there's 32 bytes.
allocated by curl_addrinfo.c:137
At 836e384, there's 12 bytes.
allocated by hostip.c:344

- abort tests



Date: 2009-11-12 00:33:33 UTC
Sender: csapuntz

And for what it's worth, the patch fixes test cases 311 and 312 which now
have memory leaks because of recent DNS hostcache behavior change.



Date: 2009-11-11 17:19:16 UTC
Sender: csapuntz

New patch attached.

Clean up in Curl_disconnect. Along with plugging the DNS ref leak in
multi.c, this allows us to simplify Curl_connect too.



Date: 2009-11-04 02:16:14 UTC
Sender: csapuntz

disconnet_conn = true in multi_runsingle but Curl_done is not always called
- which would clean up the conn->dns_entry. Don't know if it's safe to call
Curl_done so instead I cleanup in disconnect_conn clause no matter what.

Also, maintain invariant in ConnectPlease that if it returns an error then
conn->dns_entry == NULL to avoid double unlocks.



Attached File ( 1 )

Filename Description Download
dns-leak-fix.diff Fix DNS leaks Download

Changes ( 10 )

Field Old Value Date By
close_date - 2009-11-17 22:54:16 UTC bagder
status_id Open 2009-11-17 22:54:16 UTC bagder
resolution_id None 2009-11-17 22:54:16 UTC bagder
category_id http 2009-11-17 22:54:16 UTC bagder
allow_comments 1 2009-11-17 22:54:16 UTC bagder
File Added 350902: dns-leak-fix.diff 2009-11-15 01:33:52 UTC csapuntz
File Deleted 350473: 2009-11-15 01:32:56 UTC csapuntz
File Added 350473: 0001-Have-Curl_disconnect-clean-up-any-dns_entry-present.patch 2009-11-11 17:18:16 UTC csapuntz
File Deleted 349450: 2009-11-11 17:17:45 UTC csapuntz
File Added 349450: dns-redirect-leak-fix.diff 2009-11-04 02:14:53 UTC csapuntz