From owner-freebsd-stable@FreeBSD.ORG Tue May 24 21:51:54 2005 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8E3DC16A41C; Tue, 24 May 2005 21:51:54 +0000 (GMT) (envelope-from emaste@phaedrus.sandvine.ca) Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2887A43D53; Tue, 24 May 2005 21:51:53 +0000 (GMT) (envelope-from emaste@phaedrus.sandvine.ca) Received: from labgw2.phaedrus.sandvine.com ([192.168.3.11]) by mailserver.sandvine.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 24 May 2005 17:51:51 -0400 Received: by labgw2.phaedrus.sandvine.com (Postfix, from userid 12627) id C3FDC13641; Tue, 24 May 2005 17:51:53 -0400 (EDT) Date: Tue, 24 May 2005 17:51:53 -0400 From: Ed Maste To: freebsd-stable@freebsd.org Message-ID: <20050524215153.GA35718@sandvine.com> References: <20050524165907.GA20674@sandvine.com> <20050524173648.GA29183@sandvine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050524173648.GA29183@sandvine.com> User-Agent: Mutt/1.4.2.1i X-OriginalArrivalTime: 24 May 2005 21:51:51.0367 (UTC) FILETIME=[CAD63570:01C560AA] Cc: jmg@freebsd.org Subject: Re: libc_r kqueue fd leak X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2005 21:51:54 -0000 On Tue, May 24, 2005 at 01:36:48PM -0400, Ed Maste wrote: > On Tue, May 24, 2005 at 12:59:07PM -0400, Ed Maste wrote: > > > We discovered a kqueue leak when running one of our 4.x applications on > > FreeBSD 5.3 using the compat libc_r. It turns out it's caused by libc_r's > > close() failing. > > I've attached a patch which stops libc_r close() from bailing if fstat() > returns an error. This fixes the kqueue leak. This logic would also have > to make its way into the compat library via 4.x to fully resolve the issue. After a little more research it seems the kernel fix is already documented in threads/75795. Version 1.77 of kern_event.c changed kqueue_stat to just return ENXIO. We discovered the problem because each call in our app to getipnodebyname (and in turn the resolver) leaked one kqueue, which eventually used up all kernel memory and then caused a panic. I noticed that jmg originally did the kqueue locking work which removed kqueue_stat, hence the CC:. Thanks, Ed -- Ed Maste, Sandvine Incorporated