空闲时间之后libcurl奇怪的崩溃

Ste*_*goo 6 c++ gcc wxwidgets gdb libcurl

我使用libcurl进行FTP工作,它工作正常,但如果闲置一段时间它只会崩溃.这是一个回溯,尽管阅读了一段时间我无法弄清楚什么是错的.跟踪没有显示我的函数崩溃的起源,因此调试器在此处留下了孤儿.我使用线程,如果在Linux上增加值Compiler是GCC 4.7

0  0x00007fff8e09b524  addbyter  /home/stefano/Desktop/myproject/curl-7.33.0/lib/mprintf.c  914
1  0x00007fff8e09a32f  dprintf_formatf  /home/stefano/Desktop/myproject/curl-7.33.0/lib/mprintf.c  572
2  0x00007fff8e09b5a4  curl_mvsnprintf  /home/stefano/Desktop/myproject/curl-7.33.0/lib/mprintf.c  932
3  0x00007fff8e089510  Curl_failf  /home/stefano/Desktop/myproject/curl-7.33.0/lib/sendf.c  152
4  0x00007fff8e07dbf4  Curl_resolv_timeout  /home/stefano/Desktop/myproject/curl-7.33.0/lib/hostip.c  618
5  0x00007fff78012bf8  ??    
6  0x000000c300000016  ??    
7  0x00007fff8e0d3604  ??    
8  0x0000000000000002  ??    
9  0x00000000001b7740  ??    
10  0x0000000000000000  ??    
Run Code Online (Sandbox Code Playgroud)

更新1 在调试器下再次运行它并在线路遇到崩溃

FILE *fd; 
fd = fopen(files[i].c_str(), "rb"); //<---here goes the crash!
Run Code Online (Sandbox Code Playgroud)

files [i] .c_str()应该从wxString给出const*char新的BT是

0  0x00007fff8e08952a  Curl_failf  /home/stefano/Desktop/myproject/curl-7.33.0/lib/sendf.c  154
1  0x00007fff8e07dbf4  Curl_resolv_timeout  /home/stefano/Desktop/myproject/curl-7.33.0/lib/hostip.c  618
2  0x00007fff780158c8  ??    
3  0x00000000001b7730  ??    
4  0x00007fff78009808  ??    
5  0x00007fff78015e79  ??    
6  0x00007fff78009808  ??    
7  0x00007fff8c8a04a0  ??    
8  0x00007fff8e0c84ca  ftp_multi_statemach  /home/stefano/Desktop/myproject/curl-7.33.0/lib/ftp.c  3113
Run Code Online (Sandbox Code Playgroud)

Iva*_*eev 14

如果您在非主线程中使用curl,则可能会导致此类错误.当curl无法解析dns条目时,它会发送一个信号(默认情况下)以通过超时中断线程.信号不是线程安全的,可能导致崩溃.您应该使用--enable-threaded-resolver或支持c-ares来编译libcurl.

对我来说,完全禁用信号也很有用

curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1)
Run Code Online (Sandbox Code Playgroud)