cURL / Mailing Lists / curl-library / Single Mail


cURL Bug? -- Segmentation Fault (fwd)

From: Daniel Stenberg <>
Date: Tue, 3 Feb 2009 19:27:00 +0100 (CET)


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!

---------- Forwarded message ----------
Date: Tue, 3 Feb 2009 19:19:51 +0100
From: Daniel Marschall <>
Subject: cURL Bug? -- Segmentation Fault
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, "");
                 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);
                 return (res == CURLE_OK);
         } else return false;
int main(void) {
         while (true) {
                 cout << "A" << ::std::endl;
         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 Marschall
Received on 2009-02-03