cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Stack smashed when linked with pthreads

From: Tor Arntsen <tor_at_spacetec.no>
Date: Sun, 30 Jul 2006 14:49:22 +0200

On Jul 28, 20:46, Marshall Crocker wrote:
>I have an embedded system that I have cross compiled and installed curl
>on. The command line tool works fine and I can use the curl library
>from my application. I run into a problem when I link the pthreads
>library to my multithreaded app.
>
>When I link with -lpthread and -lcurl, I get the error:
>
>stack smashing detected: Segmentation fault
>
>I do not get this error if I compile with only -lpthread or only -lcurl.
>The entire embedded os (a custom version of aspisos) is compiled with
>-fstack-protector-all so that's why I'm seeing the stack smashing error
>message. I have compiled curl with --enable-thread and have tried
>compiling curl with and without -fstack-protector-all and get the same
>result.
>
>Any ideas what the problem could be? I don't have any problems when I
>link to the gpsd library and pthreads so it appears it's a curl specific
>problem but I could be wrong.

Do you get the error in runtime, when actvating a pthread?
If so you can check the stacksize with pthread_attr_getstacksize() and
usually be able to change it with pthread_attr_setstacksize().

#include <pthread.h>
#include <stdio.h>

int main (void)
{
    pthread_attr_t thread_attr;
    size_t stack_size;
    
    (void) pthread_attr_init (&thread_attr);
    (void) pthread_attr_getstacksize (&thread_attr, &stack_size);
    printf ("stack size %lu (%u kiB)\n",
            (unsigned long) stack_size, stack_size/1024);
    return (0);
}
Received on 2006-07-30