Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Dec 2000 14:34:11 -0800 (PST)
From:      chrisp@netwinsite.com
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/23364: gethostbyaddr takes longer or locks up and burns cpu when linked to -pthread
Message-ID:  <200012072234.eB7MYBv07910@freefall.freebsd.org>
Resent-Message-ID: <200012072240.eB7Me1F08592@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         23364
>Category:       misc
>Synopsis:       gethostbyaddr takes longer or locks up and burns cpu when linked to -pthread
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 07 14:40:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Chris Pugmire
>Release:        4.1.1-RELEASE
>Organization:
NetWin Ltd
>Environment:
FreeBSD news.siscom.net 4.1.1-RELEASE FreeBSD 4.1.1-RELEASE #2: Mon Nov 27 14:21:06 EST 2000     root@news.siscom.net:/usr/src/sys/compile/GENERIC  i386

>Description:
With a test program doing ip number to name lookups for a number that
does not have an entry if the program is linked with -pthread then
it takes 30 seconds longer and burns 100% cpu until it times out.

I believe it sometimes never times out or takes much longer but cannot
reproduce this in a test case.

Note that no actual threads are used, this program is simply linked
with -pthread and then behaves in this odd way.

>How-To-Repeat:
Sample code included:

(include headers...)
int do_reverse(char *ipnum);
int main(int argc, char *argv[])
{
	int i;
	if (argc<2) {
usage:		printf("Usage: testdns -rev n.n.n.n\n");
		return 0;
	}
	tcp_startup();
	for (i=1; i<argc; i++) {
		if (strncmp(argv[i],"-rev",4)==0) {
			do_reverse(argv[++i]);
		} else {
			printf("Invalid option (%s)\n",argv[i]);	
			goto usage;
		}
	}
	return 0;
}
int do_reverse(char *ipnum)
{
        struct sockaddr_in sin;
        struct hostent *hp;
	int start;
	start = time(NULL);

	sin.sin_addr.s_addr = inet_addr(ipnum);
	printf("Looking up (%s)\n",ipnum);
        hp = gethostbyaddr( (char *) &(sin.sin_addr), sizeof(sin.sin_addr), AF_INET);
	printf("Result %p\n",hp);
	if (hp!=NULL) if (hp->h_name!=NULL) {
		printf("result (%s)\n",hp->h_name);
	}
	printf("Delay %d seconds\n",time(NULL)-start);
	return TRUE;
}
Example output with the same program linked different ways:

news# ./testdns_nopthread -rev 160.79.54.12 
Looking up (160.79.54.12)
Result 0x0
Delay 80 seconds

news# ./testdns_pthread -rev 160.79.54.12
Looking up (160.79.54.12)
Result 0x0
Delay 111 seconds

(and in the second case watching top will show the testdns process
burning cpu)
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200012072234.eB7MYBv07910>