Bug 462217

Summary: libcurl hanging up on series requests to ssl sites
Product: [Fedora] Fedora Reporter: Dmitriy Trubenkov <403rus>
Component: curlAssignee: Rob Crittenden <rcritten>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 9CC: chkr, jnovy, rcritten, wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-09-24 23:59:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
fix misplaced PR_Unlock, replaces existing patch in spec none

Description Dmitriy Trubenkov 2008-09-14 11:47:42 UTC
Description of problem:
I'm using curl in perl via WWW::Curl::Easy for serial requests to site via https. After ~2-3 requests script hanging up. Strace show that all stopped on some futex, i think it's appear from that fix: "- add thread safety to libcurl NSS cleanup() functions (#459297)"

Version-Release number of selected component (if applicable):
7.18.2-5

How reproducible:
Systematic

Steps to Reproduce:
create and run test.pl:
#!/usr/bin/perl

use strict;
use warnings;
use Carp qw(croak);
use WWW::Curl::Easy;

my $resp;
my $curl = WWW::Curl::Easy->new() or die "curl init failed!\n";
$curl->setopt( CURLOPT_HTTP_VERSION,      1.0 );
$curl->setopt( CURLOPT_FOLLOWLOCATION,    1 );
$curl->setopt( CURLOPT_MAXCONNECTS,       5 );
$curl->setopt( CURLOPT_DNS_CACHE_TIMEOUT, 30 );
$curl->setopt( CURLOPT_TIMEOUT,           30 );
$curl->setopt( CURLOPT_AUTOREFERER,       1 );
my @myheaders = (
    "Expect:",
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; ru; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4",
"Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5",
    "Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3",
    "Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7",
    "Keep-Alive: 300",
    "Connection: keep-alive"
);
$curl->setopt( CURLOPT_HTTPHEADER, \@myheaders );
$curl->setopt( CURLOPT_HTTPGET,    1 );
$curl->setopt( CURLOPT_USERAGENT,
'Mozilla/5.0 (Windows; U; Windows NT 5.0; ru; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4'
);
$curl->setopt( CURLOPT_VERBOSE, 1 );

my $url;
$url = 'https://secure.bigbutton.com.au/secure/bigbutton/lottosyndicate/about.php';
$curl->setopt( CURLOPT_URL, $url );
croak "error on get front page" if ( $curl->perform() != 0 );
$curl->setopt( CURLOPT_URL, $url );
croak "error on get front page" if ( $curl->perform() != 0 );
$curl->setopt( CURLOPT_URL, $url );
croak "error on get front page" if ( $curl->perform() != 0 );
$curl->setopt( CURLOPT_URL, $url );
croak "error on get front page" if ( $curl->perform() != 0 );
  
Actual results:
Hanging up. strace last lines(strace perl test.pl):
write(2, "About to connect() to secure.big"..., 60About to connect() to secure.bigbutton.com.au port 443 (#0)
) = 60
clock_gettime(CLOCK_MONOTONIC, {118999, 657527620}) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
write(2, "* ", 2* )                       = 2
write(2, "  Trying 203.57.68.11... ", 25  Trying 203.57.68.11... ) = 25
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
connect(3, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("203.57.68.11")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {118999, 658032963}) = 0
poll([{fd=3, events=POLLOUT, revents=POLLOUT}], 1, 30000) = 1
getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
write(2, "* ", 2* )                       = 2
write(2, "connected\n", 10connected
)             = 10
clock_gettime(CLOCK_MONOTONIC, {119000, 75875159}) = 0
write(2, "* ", 2* )                       = 2
write(2, "Connected to secure.bigbutton.co"..., 66Connected to secure.bigbutton.com.au (203.57.68.11) port 443 (#0)
) = 66
clock_gettime(CLOCK_MONOTONIC, {119000, 76270550}) = 0
futex(0x8b40f68, FUTEX_WAIT_PRIVATE, 2, NULL


Expected results:
Don't hang up :)

Additional info:
With openssl version of curl no problem. Please make openssl version of libcurl available as option - there many problems with curl+nss.

Comment 1 Rob Crittenden 2008-09-16 15:30:45 UTC
Created attachment 316858 [details]
fix misplaced PR_Unlock, replaces existing patch in spec

Indeed the problem was a locking issue due to a misplaced PR_Unlock().

This patch replaces the existing curl-7.18.2-nss-thread-safety.patch

I'll submit this fix upstream too though it doesn't appear that they have accepted the original patch yet.

Comment 2 Christian Krause 2008-09-19 14:29:37 UTC
(In reply to comment #1)
> Created an attachment (id=316858) [details]
> fix misplaced PR_Unlock, replaces existing patch in spec
> 
> Indeed the problem was a locking issue due to a misplaced PR_Unlock().
> 
> This patch replaces the existing curl-7.18.2-nss-thread-safety.patch

I've tested this new patch and now SSL connections via libcurl works as expected again. Thanks!

It would be great if a new version of libcurl could be pushed out soon for F9! ;-)

Comment 3 Fedora Update System 2008-09-19 17:47:18 UTC
curl-7.18.2-6.fc9 has been submitted as an update for Fedora 9.
http://admin.fedoraproject.org/updates/curl-7.18.2-6.fc9

Comment 4 Fedora Update System 2008-09-19 17:48:48 UTC
curl-7.18.2-6.fc8 has been submitted as an update for Fedora 8.
http://admin.fedoraproject.org/updates/curl-7.18.2-6.fc8

Comment 5 Fedora Update System 2008-09-24 23:59:24 UTC
curl-7.18.2-6.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2008-09-25 00:23:19 UTC
curl-7.18.2-6.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.