开发者

libcurl (7.19,7) crashes with _mdns_query_callback on OSX (10.6.8)

开发者 https://www.devze.com 2023-03-29 02:52 出处:网络
my application crashes using libcurl for some unknown reason. It crashed spontaneously after many loops of the same code while using Guard Malloc.

my application crashes using libcurl for some unknown reason. It crashed spontaneously after many loops of the same code while using Guard Malloc.

Libcurl version information:

curl 7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3 Protocols: tftp ftp telnet dict ldap http file https ftps Features: GSS-Negotiate IPv6 Largefile NTLM SSL libz

Sourcecode:

char * process_url(char * url,char * post){
    CURLcode res;
    curl_easy_reset(curl);
    if(curl){
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);
        curl_easy_setopt(curl, CURLOPT_POSTREDIR,CURL_REDIR_POST_ALL);
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,1L);
        curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,write_to_string);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
        if (post) {
            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post);
        }
        ResponseStruct result;开发者_如何学运维
        result.response = malloc(sizeof(char));
        result.response[0] = '\0';
        result.length = 1;
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &result);
        res = curl_easy_perform(curl); //CRASHED HERE
        if (res) {
            printf("CURL FAILED WITH ERROR CODE %i\n",(int)res);
            return NULL;
        }
        sec_sleep(1); //Prevent passing float limit.
        return result.response;
    }
    return NULL;
}

Here is the function stack:

#0  0x7fff869d22ae in _mdns_query_callback
#1  0x7fff869bfc29 in handle_query_response
#2  0x7fff869bf08b in DNSServiceProcessResult
#3  0x7fff869d1a71 in _mdns_query_mDNSResponder
#4  0x7fff869d0c61 in _mdns_search
#5  0x7fff869cfffc in _mdns_addrinfo
#6  0x7fff869cf059 in search_addrinfo
#7  0x7fff869cea7a in si_addrinfo
#8  0x7fff869ce48d in getaddrinfo
#9  0x7fff831695fc in Curl_getaddrinfo_ex
#10 0x7fff83164a3d in Curl_getaddrinfo
#11 0x7fff8313dda3 in Curl_resolv
#12 0x7fff8313dfb6 in Curl_resolv_timeout
#13 0x7fff8314b225 in resolve_server
#14 0x7fff83150aaf in create_conn
#15 0x7fff83150c08 in Curl_connect
#16 0x7fff8315b817 in Curl_perform
#17 0x100001126 in process_url at main.c:90
#18 0x1000013f7 in cancel_outstanding_order at main.c:158
#19 0x100002aac in main at main.c:554

There are no threads used in the program. I checked my data int he debugger and it is fine. libcurl doesn't like something. Are there any solutions?

Thank you.


getaddrinfo() is a libc call that your operating system (OS X) provides.

As libcurl uses the exact same name resolve function for many operating systems where it doesn't crash I would say that it indicate that the problem is truly in OS X and not in libcurl.

I've never seen this bug reported though, which is odd if it truly is a bug in OS X but then I also never saw it reported on libcurl. Possibly that would suggest that the problem is rather in your application...

If you can repeat the problem with a stand-alone example program, then providing that to the curl project and ask them (us) to help you debug it could be an idea. If you cannot repeat it with a small program it would be another indication that the problem is rather caused by your application!

0

精彩评论

暂无评论...
验证码 换一张
取 消