I have coded a program that works fine on windows, then I had to use it on linux so I coded the needed things for it to work on linux. What I mainly changed was the thread creation function ;
void thread_create(void *(*threadfunc)(void *), void *u)//linux
{
#ifdef linux
pthread_t id;
pthread_create(&id, NULL, threadfunc, u);
#endif
}
void thread_create(void (*threadfunc)(void *), void *u)//windows
{
#ifndef linux
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc, u, 0, NULL);
#endif
}
The program has a lot of threads. I used gdb to see where it crashes, and the crash always occures at the curl_easy_perform function. Note that I am using this function a lot of times before where I know it will crash, the program never crashes before that point. When I am using them before that point, I'm not sending any data with POST/GET methods, I'm only getting informations from pages without sending any data.
So gdb always tells me :
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffdf65c700 (LWP 26488)]
0x00007ffff6fb0360 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007ffff6fb0360 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00000000004a1e70 in readmoredata ()
#2 0x00000000004b33d7 in Curl_fillreadbuffer ()
#3 0x00000000004b40fc in Curl_readwrite ()
#4 0x000000000049b3bc in multi_runsingle ()
#5 0x000000000049c275 in curl_multi_perform ()
#6 0x00000000004972c3 in curl_easy_perform ()
I would like to give you something you can make tests on, but I really can't. The program has thousands of lines.