From owner-freebsd-threads@FreeBSD.ORG Sun Apr 18 14:00:22 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F2CD816A535 for ; Sun, 18 Apr 2004 14:00:21 -0700 (PDT) Received: from mta4.rcsntx.swbell.net (mta4.rcsntx.swbell.net [151.164.30.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id C2C0043D3F for ; Sun, 18 Apr 2004 14:00:21 -0700 (PDT) (envelope-from mbsd@pacbell.net) Received: from atlas (adsl-64-160-45-15.dsl.snfc21.pacbell.net [64.160.45.15]) i3IL0Jh8024718; Sun, 18 Apr 2004 16:00:20 -0500 (CDT) Date: Sun, 18 Apr 2004 14:00:19 -0700 (PDT) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= X-X-Sender: mikko@atlas.home To: Ivan Voras In-Reply-To: <4082A88E.5060605@geri.cc.fer.hr> Message-ID: <20040418133853.A31913@atlas.home> References: <4082A88E.5060605@geri.cc.fer.hr> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-threads@freebsd.org Subject: Re: Siege segfaulting X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Apr 2004 21:00:22 -0000 On Sun, 18 Apr 2004, Ivan Voras wrote: > I was asked to send details about a problem I found with siege on > 5.2-current. Here is my original post from current@freebsd.org: > > There are problems (segfault) running siege (web benchmark program) on a > recent FreeBSD 5.2-current (a few days ago). When I switch it to libc_r > via libmap.conf, everything works ok. Since the software is ported to a > large number of platforms and works ok, it's likely a libpthread bug Or not. Last time I tried to use siege, I ran into so many bugs that I gave up on it. > Siege uses threading to make simultaneous HTTP requests. I tried with a > recent release (2.59) and beta (2.60) version if siege, with same behaviour. > > This does not happend with small number of threads (2-3), but if I > specify a larger number (usually 8+), it crashes in the middle of work. Looks like a porting error; siege is calling gethostbyname(), which is non-reentrant. Try this patch (put it into siege/files/patch-src::sock.c) and rebuild the port: % cd /usr/ports/benchmarks/siege && cat files/patch-src::sock.c --- src/sock.c.orig Sun Apr 18 13:34:08 2004 +++ src/sock.c Sun Apr 18 13:34:43 2004 @@ -132,7 +132,7 @@ if((gethostbyname_r( hn, &hent, hbf, sizeof(hbf), &hp, &herrno ) < 0)){ hp = NULL; } -#elif defined(sun) +#elif defined(sun) || defined(__FreeBSD__) # ifdef HAVE_GETIPNODEBYNAME hp = getipnodebyname( hn, AF_INET, 0, &herrno ); # else /* default use gethostbyname_r*/ @@ -155,7 +155,7 @@ if( hp == NULL ){ return -1; } memset((void*) &cli, 0, sizeof( cli )); memcpy( &cli.sin_addr, hp->h_addr, hp->h_length ); -#if defined(sun) +#if defined(sun) || defined(__FreeBSD__) # ifdef HAVE_FREEHOSTENT freehostent(hp); # endif/*HAVE_FREEHOSTENT*/ @@ -257,6 +257,7 @@ return( C->sock ); } +#if 0 /* unused */ /** * local function * returns hostent based on OS specifics @@ -313,6 +314,7 @@ xfree( buf ); return( hp ); } +#endif /** * makes the socket non-blocking, I ran some quick tests on a less than a month old -CURRENT, and with this patch siege runs to completion. Without the patch, siege crashes within half a minute. $.02, /Mikko