libcurl (7.19,7) 在 OSX (10.6.8) 上因 _mdns_query_callback 崩溃

发布于 2024-11-30 14:41:47 字数 2532 浏览 0 评论 0原文

我的应用程序因某些未知原因而使用 libcurl 崩溃。使用 Guard Malloc 时,在多次循环相同代码后,它会自发崩溃。

Liburl版本信息:

curl 7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3 协议: tftp ftp telnet dict ldap http 文件 https ftps 功能:GSS-协商 IPv6 大型文件 NTLM SSL libz

源代码:

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;
}

这是函数堆栈:

#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

程序中没有使用线程。我在调试器中检查了我的数据,一切正常。 libcurl 不喜欢某些东西。有什么解决办法吗?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听不够的曲调 2024-12-07 14:41:47

getaddrinfo() 是操作系统 (OS X) 提供的 libc 调用。

由于 libcurl 在许多操作系统中使用完全相同的名称解析函数,并且不会崩溃,因此我想说这表明问题确实存在于 OS X 中,而不是 libcurl 中。

不过,我从未见过这个错误的报告,如果它确实是 OS X 中的错误,那就很奇怪了,但我也从未在 libcurl 上看到过它的报告。可能这表明问题出在您的应用程序中......

如果您可以使用独立的示例程序重复该问题,那么将其提供给curl项目并要求他们(我们)帮助您调试它可能是一个主意。如果您不能用一个小程序重复它,这将再次表明问题是由您的应用程序引起的!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文