Subject: | Segfault if curl handle persists until global destruction |
System: Fedora 14 x86_64
Perl: perl-5.12.2-140.fc14
libcurl: libcurl-7.21.0-6.fc14
WWW::Curl: perl-WWW-Curl-4.14-1.fc14
If a curl easy handle survives until global destruction due to a
circular reference or closure, it will then be released *after*
curl_global_cleanup() has already been called by WWW::Curl's END block.
The attached program demonstrates a segfault that results when making
an HTTPS connection:
#0 nssTrustDomain_LockCertCache (td=0x0) at tdcache.c:405
#1 0x00000036d0067250 in nssCertificate_Destroy (c=0xf092e0)
at certificate.c:144
#2 0x00000036d040b369 in ssl3_CleanupPeerCerts (ss=<value optimized out>)
at ssl3con.c:7750
#3 0x00000036d04147d3 in ssl3_DestroySSL3Info (ss=0xf1afe0) at
ssl3con.c:9458
#4 0x00000036d04216fa in ssl_DestroySocketContents (ss=0xf1afe0)
at sslsock.c:407
#5 0x00000036d0422862 in ssl_FreeSocket (ss=0xf1afe0) at sslsock.c:478
#6 0x00000036d04198e8 in ssl_DefClose (ss=0xf1afe0) at ssldef.c:233
#7 0x0000003265c450b5 in Curl_nss_close (conn=<value optimized out>,
sockindex=0) at nss.c:1042
#8 0x0000003265c20841 in Curl_disconnect (conn=0xdd87d0) at url.c:2628
#9 0x0000003265c209b5 in ConnectionKillOne (data=0xe540a0) at url.c:3067
#10 0x0000003265c229e0 in close_connections (data=0xe540a0) at url.c:274
#11 Curl_close (data=0xe540a0) at url.c:493
#12 0x00007f749e20b4c4 in perl_curl_easy_delete (my_perl=0xd1d010,
cv=<value optimized out>) at Curl.xs:158
#13 XS_WWW__Curl__Easy_DESTROY (my_perl=0xd1d010, cv=<value optimized out>)
at Curl.xs:963
#14 0x00000032dc4b0dd0 in Perl_pp_entersub (my_perl=0xd1d010) at
pp_hot.c:2882
#15 0x00000032dc44ad94 in Perl_call_sv (my_perl=0xd1d010, sv=0xdcc5d0,
flags=45) at perl.c:2609
#16 0x00000032dc4b677a in Perl_sv_clear (my_perl=0xd1d010, sv=0xd20fc0)
at sv.c:5720
#17 0x00000032dc4b6fa2 in Perl_sv_free2 (my_perl=0xd1d010, sv=0xd20fc0)
at sv.c:5985
#18 0x00000032dc4b22f1 in S_visit (my_perl=0xd1d010,
f=0x32dc4b7580 <do_clean_objs>, flags=2048, mask=2048) at sv.c:440
#19 0x00000032dc4b28f1 in Perl_sv_clean_objs (my_perl=0xd1d010) at sv.c:548
#20 0x00000032dc44cae5 in perl_destruct (my_perl=0xd1d010) at perl.c:770
#21 0x0000000000400d11 in main (argc=2, argv=0x7fffb8b9f148,
env=0x7fffb8b9f160) at perlmain.c:126
Subject: | crash.pl |
#!/usr/bin/perl
use WWW::Curl::Easy;
use strict;
use warnings;
my $curl = WWW::Curl::Easy->new;
sub run {
$curl->setopt(CURLOPT_URL, "https://www.cs.cmu.edu/");
my $fh;
open($fh, ">", "/dev/null");
$curl->setopt(CURLOPT_WRITEDATA, $fh);
$curl->perform;
}
run();