curl-library
cURL Bug? -- Segmentation Fault (fwd)
From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 3 Feb 2009 19:27:00 +0100 (CET)
Date: Tue, 3 Feb 2009 19:27:00 +0100 (CET)
Hey
This was posted directly to the tracker list (which is revered for posts from
the bug tracker only) so I'm forwarding it here instead!
-- / daniel.haxx.se ---------- Forwarded message ---------- Date: Tue, 3 Feb 2009 19:19:51 +0100 From: Daniel Marschall <info_at_daniel-marschall.de> To: curl-tracker_at_cool.haxx.se Subject: cURL Bug? -- Segmentation Fault Hello. I have a problem with cURLlib for C++. I wrote a daemon tool which has asynchronous function calls and where a websites are called every 60 seconds with a timeout of 30 seconds. The daemon crashed after a few hours. On the screen I see "Speicherzugriffsfehler" (German for "Memory access error" = Segmentation Fault?) Now I could create a test program where the access violation appears after a few seconds: I use G++ on a Linux Debian Etch with LibCURL3 Compile with g++ -g -Wall -ansi -pedantic -lcurl -o programmname main.c; And that is the full source code: #include <stdlib.h> #include <stdio.h> #include <iostream> #include <sstream> #include <string.h> #include <curl/curl.h> using namespace std; bool http_call () { CURL *curl; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/"); string buffer; curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1); // 1 Sekunde provoziert die AV stark CURLcode res; res = curl_easy_perform(curl); curl_easy_cleanup(curl); return (res == CURLE_OK); } else return false; } int main(void) { while (true) { cout << "A" << ::std::endl; http_call(); sleep(2); } return 0; } When I set the interval to 2 seconds and the timeout to 1 second, the bug appears very often. Usually, this should not be. The HTTP call should be unsuccessful, but the program may not crash because of that. With the GDB Tool I saw that the segmentation fault probably comes from curl_escape() everytime. Is this a bug in CURL? Please reply. I can append the original linux binary file I compiled, if neccessary. Best regards Daniel MarschallReceived on 2009-02-03