cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl-7.17.1 crashes on getprotobyname() problem in RHEL5.1

From: Jean-François Bertrand <jeffy_at_broadsoft.com>
Date: Fri, 02 May 2008 11:26:04 -0400

-- Problem description --
libcurl is causing segfault on calls to getprotobyname("ftp") when doing
simultaneous access (from many threads) to unavailable HTTP resources
using libcurl-7.17.1. This occurs with RedHat Enterprise Linux 5.1
running on quad-core Intel(R) Xeon(R) CPU 5150 @ 2.66GHz system.

-- Build options --
Curl was built with the following option:
export CC=gcc
export CFLAGS="-g -O2"
./configure --without-zlib --without-ssl --prefix=$CURL_ROOT
--disable-shared --disable-gopher --disable-ldap --disable-dict
--disable-telnet --disable-debug --enable-thread
make
make install

-- Stack trace --
Here is a typical stack trace we would get when this problem occurred:

(gdb) bt
#0 0x00002aaaabab3edd in fgets () from /lib64/libc.so.6
#1 0x000000000088ebbf in pr_next (this=0x2aafbc1c9ec3) at lcl_pr.c:209
#2 0x000000000088edd0 in pr_byname (this=0x1c493630, name=0xa08b90
"tcp") at lcl_pr.c:158
#3 0x0000000000886654 in pr_byname (this=0x2aafbc1c9ec3, name=0xa08b90
"tcp") at gen_pr.c:140
#4 0x0000000000872e3e in getprotobyname (name=0xa08b90 "tcp") at
getprotoent.c:111
#5 0x000000000083e34a in tcpnodelay (conn=0x2aafbc1c9ec3, sockfd=9213)
at connect.c:630
#6 0x000000000083ec13 in Curl_connecthost (conn=0x2aafbc1c9ec3,
remotehost=0x23fd, sockconn=0x0, addr=0x2aaf00706374,
    connected=0x23fd <Address 0x23fd out of bounds>) at connect.c:894
#7 0x000000000083747c in SetupConnection (conn=0x2aafbc1c9ec3,
hostaddr=0x23fd, protocol_done=0x0) at url.c:4247
#8 0x0000000000834d7c in Curl_connect (data=0x2aafbc1c9ec3,
in_connect=0x23fd, asyncp=0x0, protocol_done=0x2aaf00706374 "") at
url.c:4319
#9 0x000000000083d308 in Curl_connect_host (data=0x2aafbc1c9ec3,
conn=0x23fd) at transfer.c:2333
#10 0x000000000083a676 in Curl_perform (data=0x2aafbc1c9ec3) at
transfer.c:2429
#11 0x000000000082d455 in curl_easy_perform (curl=0x2aafbc1c9ec3) at
easy.c:498

-- Workaround --
Removing the call to getprotobyname in curl-7.17.1/lib/connect.c (lines
629-633 inclusively) fixed our problem.

The same problem and solution also applies with libcurl 7.18.1.

/JF
Received on 2008-05-02