From owner-freebsd-current@FreeBSD.ORG Mon Jun 7 20:39:18 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 777E816A4CE for ; Mon, 7 Jun 2004 20:39:18 +0000 (GMT) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0DB0943D54 for ; Mon, 7 Jun 2004 20:39:18 +0000 (GMT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.12.11/8.12.11) with ESMTP id i57KcLRf023579; Mon, 7 Jun 2004 16:38:21 -0400 (EDT) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)i57KcL4i023576; Mon, 7 Jun 2004 16:38:21 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Mon, 7 Jun 2004 16:38:21 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: Arjan van Leeuwen In-Reply-To: <200406072216.29044.avleeuwen@piwebs.com> Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-840199968-1086640701=:88690" cc: freebsd-current@freebsd.org cc: "David A. Benfell" Subject: Re: file descripter leak in current with Qmail? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2004 20:39:18 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-840199968-1086640701=:88690 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 7 Jun 2004, Arjan van Leeuwen wrote: > On Monday 07 June 2004 21:42, you wrote: > > On Mon, 7 Jun 2004, Arjan van Leeuwen wrote: > > > > > In terms of debugging it: your first task it to identify if there's > > > > > one process that's holding all the fd's, or if it is distributed over > > > > > many proceses. After that, you want to track down what kind of fd is > > > > > being left open, which may help you track down why it's left open... > > > > > > > > Just as I'm reading this, I'm seeing the same thing on my -CURRENT > > > > server, which has a _very_ low load (atm, it's only routing the > > > > internet traffic for 3 users and serving SMTP for 2 of them). I'm also > > > > running qmail. The kernel is from June 6. How do I go about > > > > investigating this further? > > > > > > Replying to myself - > > > fstat shows all open files evenly distributed among the running > > > processes. > > > > It could be that this is related to the esd file descriptor leak problem > > also being reported. You might also try the attached patch. > > I get a panic (address not allocated) when using the patch. I can't > write down any useful details about it right now, because although the > server has only 3 users, they're very disconcerned when I disrupt their > internet traffic :). Doh. Sorry about that. Revised patch attached. I'm able to test the leak with the attached C file, and on my test box (now that it doesn't panic), the leak appears fixed for non-blocking accepts. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Senior Research Scientist, McAfee Research Index: uipc_syscalls.c =================================================================== RCS file: /data/ncvs/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.187 diff -u -r1.187 uipc_syscalls.c --- uipc_syscalls.c 7 Jun 2004 09:59:50 -0000 1.187 +++ uipc_syscalls.c 7 Jun 2004 20:21:30 -0000 @@ -253,7 +253,7 @@ { struct filedesc *fdp; struct file *nfp = NULL; - struct sockaddr *sa; + struct sockaddr *sa = NULL; socklen_t namelen; int error; struct socket *head, *so; @@ -285,7 +285,7 @@ if ((head->so_state & SS_NBIO) && TAILQ_EMPTY(&head->so_comp)) { ACCEPT_UNLOCK(); error = EWOULDBLOCK; - goto done; + goto noconnection; } while (TAILQ_EMPTY(&head->so_comp) && head->so_error == 0) { if (head->so_state & SS_CANTRCVMORE) { @@ -296,14 +296,14 @@ "accept", 0); if (error) { ACCEPT_UNLOCK(); - goto done; + goto noconnection; } } if (head->so_error) { error = head->so_error; head->so_error = 0; ACCEPT_UNLOCK(); - goto done; + goto noconnection; } so = TAILQ_FIRST(&head->so_comp); KASSERT(!(so->so_qstate & SQ_INCOMP), ("accept1: so SQ_INCOMP")); --0-840199968-1086640701=:88690 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="accept_test.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: I2luY2x1ZGUgPHN5cy90eXBlcy5oPg0KI2luY2x1ZGUgPHN5cy9zb2NrZXQu aD4NCg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCg0KI2luY2x1ZGUgPGZj bnRsLmg+DQojaW5jbHVkZSA8c3RkaW8uaD4NCiNpbmNsdWRlIDxzdGRsaWIu aD4NCiNpbmNsdWRlIDxzdHJpbmcuaD4NCg0KaW50DQptYWluKGludCBhcmdj LCBjaGFyICphcmd2W10pDQp7DQoJc3RydWN0IHNvY2thZGRyX2luIHNpbjsN Cglzb2NrbGVuX3Qgc2l6ZTsNCglpbnQgaSwgczsNCg0KCXMgPSBzb2NrZXQo UEZfSU5FVCwgU09DS19TVFJFQU0sIDApOw0KCWlmIChzID09IC0xKSB7DQoJ CXBlcnJvcigic29ja2V0Iik7DQoJCWV4aXQoLTEpOw0KCX0NCg0KCWJ6ZXJv KCZzaW4sIHNpemVvZihzaW4pKTsNCglzaW4uc2luX2xlbiA9IHNpemVvZihz aW4pOw0KCXNpbi5zaW5fZmFtaWx5ID0gQUZfSU5FVDsNCglzaW4uc2luX2Fk ZHIuc19hZGRyID0gSU5BRERSX0FOWTsNCglzaW4uc2luX3BvcnQgPSBodG9u cyg4MDgwKTsNCg0KCWlmIChiaW5kKHMsIChzdHJ1Y3Qgc29ja2FkZHIgKikg JnNpbiwgc2l6ZW9mKHNpbikpICE9IDApIHsNCgkJcGVycm9yKCJiaW5kIik7 DQoJCWV4aXQoLTEpOw0KCX0NCg0KCWlmIChsaXN0ZW4ocywgLTEpICE9IDAp IHsNCgkJcGVycm9yKCJsaXN0ZW4iKTsNCgkJZXhpdCgtMSk7DQoJfQ0KDQoJ aSA9IDE7DQoJaWYgKGZjbnRsKHMsIE9fTk9OQkxPQ0ssICZpKSAhPSAwKSB7 DQoJCXBlcnJvcigiT19OT05CTE9DSyIpOw0KCQlleGl0KC0xKTsNCgl9DQoN Cglmb3IgKGkgPSAwOyBpIDwgMTAwMDsgaSsrKQ0KCQlhY2NlcHQocywgKHN0 cnVjdCBzb2NrYWRkciAqKSZzaW4sICZzaXplKTsNCg0KCXByaW50ZigiZmQg cmV0dXJuZWQgYnkgb3BlbigvZGV2L251bGwpID0gJWRcbiIsDQoJICAgb3Bl bigiL2Rldi9udWxsIiwgT19SRE9OTFkpKTsNCg0KCXJldHVybiAoMCk7DQp9 DQo= --0-840199968-1086640701=:88690--