Haxx ad

curl's project page on


cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

curl library bug

From: Viktor Molnar <>
Date: Wed, 23 Jun 2010 02:08:39 -0800
I have been trying this example:
and it's working fine.

But, when I made a few changes (num of threads and URL), it's
generated an 'segmentation fault'.

I had same problem on:
 - 2.6.28-19-generic #61-Ubuntu  |  curl 7.18.2
 - 2.6.34-ARCH #1 SMP  |  curl 7.20.1


Here is my code:

#include <stdio.h>
#include <pthread.h>
#include <curl/curl.h>
#define NUMT 10
  List of URLs to fetch.
  If you intend to use a SSL-based protocol here you MUST setup the OpenSSL
  callback functions as described here:
const char * const urls[NUMT]= {
static void *pull_one_url(void *url)
  CURL *curl;
  curl = curl_easy_init();
  curl_easy_setopt(curl, CURLOPT_URL, url);
  curl_easy_setopt(curl, CURLOPT_TIMEOUT, 1);
  curl_easy_perform(curl); /* ignores error */
  return NULL;
   int pthread_create(pthread_t *new_thread_ID,
   const pthread_attr_t *attr,
   void * (*start_func)(void *), void *arg);
int main(int argc, char **argv)
  pthread_t tid[NUMT];
  int i;
  int error;
  /* Must initialize libcurl before any threads are started */
  for(i=0; i< NUMT; i++) {
    error = pthread_create(&tid[i],
                           NULL, /* default attributes please */
                           (void *)urls[i]);
    if(0 != error)
      fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error);
      fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]);
  /* now wait for all threads to terminate */
  for(i=0; i< NUMT; i++) {
    error = pthread_join(tid[i], NULL);
    fprintf(stderr, "Thread %d terminated\n", i);
  return 0;

Try IM ToolPack Send your photos by email in seconds...
Try FREE IM ToolPack at
Works in all emails, instant messengers, blogs, forums and social networks.

List admin:
Received on 2010-06-23

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET