On Sat, 2010-09-25 at 23:30 +0200, Guilhem Bonnefille wrote:
Hi,
I'm testing ETag branch.
I encountered some segfault. The segfault occurs in a
curl_check_header function, called by curl_easy_perform. With gdb I
found that the error is certainly due to memory corruption. So I ran
viking under valgrind. The latter reports that the matter is a read
from a freed memory.
But the most surprising is that the free occurs AFTER the context of the
error:
- free at curl_download.c:216
- curl_easy_perform at curl_download.c:189
(line numbers can be incorrect as I played with code to understand).
So, I naturally think about multi-thread issue. But I do not
understand what can go wrong.
Any tip welcome.
What I think happens is:
1) We first do a request for a tile with an ETag and apply a custom
header, this gets set into the conn-data-set.headers pointer
2) The header gets freed, but the set.headers pointer is left as a
dangling reference to the memory
3) A subsequent request is generated for a tile without an etag so we do
not overwrite the set.headers pointer and it keeps the old, invalid
value and the HTTP request code tries to reference it.
I believe the following change should fix it by ensuring the dangling
pointer gets cleared during step (2).
diff --git a/src/curl_download.c b/src/curl_download.c
index 0eb2b45..2e7a7ef 100644
--- a/src/curl_download.c
+++ b/src/curl_download.c
@@ -213,8 +213,10 @@ int curl_download_uri ( const char *uri, FILE *f,
DownloadMapOptions *options, D
}
if (!handle)
curl_easy_cleanup ( curl );
- if (curl_send_headers)
+ if (curl_send_headers) {
curl_slist_free_all(curl_send_headers);
+curl_easy_setopt ( curl, CURLOPT_HTTPHEADER , NULL);
+ }
return res;
}
Jon
--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
___
Viking-devel mailing list
Viking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/