From dwhite@gumbysoft.com  Fri Aug 22 13:52:44 2003
Return-Path: <dwhite@gumbysoft.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7D01716A4BF
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Aug 2003 13:52:44 -0700 (PDT)
Received: from carver.gumbysoft.com (carver.gumbysoft.com [66.220.23.50])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2958643F85
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Aug 2003 13:52:44 -0700 (PDT)
	(envelope-from dwhite@gumbysoft.com)
Received: by carver.gumbysoft.com (Postfix, from userid 1000)
	id 1FF9872DD4; Fri, 22 Aug 2003 13:52:44 -0700 (PDT)
Message-Id: <20030822205244.1FF9872DD4@carver.gumbysoft.com>
Date: Fri, 22 Aug 2003 13:52:44 -0700 (PDT)
From: Doug White <dwhite@gumbysoft.com>
Reply-To: Doug White <dwhite@gumbysoft.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: gethostbyname_r leaks kqueue descriptors
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         55879
>Category:       bin
>Synopsis:       gethostbyname leaks kqueue descriptors in pthreads
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 22 14:00:00 PDT 2003
>Closed-Date:    Fri Oct 10 18:21:41 PDT 2003
>Last-Modified:  Fri Oct 10 18:21:41 PDT 2003
>Originator:     Doug White
>Release:        FreeBSD 4.8-STABLE i386
>Organization:
>Environment:
System: FreeBSD carver.gumbysoft.com 4.8-STABLE FreeBSD 4.8-STABLE #6: Sat May 3 17:51:53 PDT 2003 root@carver.gumbysoft.com:/usr/obj/usr/src/sys/CARVER i386


	
>Description:
gethostbyname(3) does not properly close the kqueue descriptor it uses to 
wait for DNS query responses in pthreads. Threaded programs that repeatedly call
the gethostbyname(3) function eventually run out of file descriptors.  
kqueue descriptors are only visible with lsof, so if you're going to go look,
don't use fstat(8).
>How-To-Repeat:
I found this with python -- the default python port compiles with thread
support, which enables use of pthreads.  Recompiling the port with
WITHOUT_THREADS and running the test program finds no buildup of kqueue
descriptors.  I can produce a C pthreads program if desired, I just don't
have my book handy right here.  A test C program that just calls 
gethostbyname(3) in a loop doesn't leak either, so it seems limited to the
threadsafe variant.
>Fix:

	


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: kris 
State-Changed-When: Wed Oct 8 15:19:37 PDT 2003 
State-Changed-Why:  
Is this still broken?  I am no longer seeing the symptoms of this 
here. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55879 
State-Changed-From-To: feedback->closed 
State-Changed-By: dwhite 
State-Changed-When: Fri Oct 10 18:21:07 PDT 2003 
State-Changed-Why:  
Problem no longer reproduces, although I haven't found a specific commit 
that would have fixed it.  Hopefully it wasn't a python bug :) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55879 
>Unformatted:
