From owner-freebsd-current@FreeBSD.ORG Sun Jun 30 21:23:42 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3B115D3B for ; Sun, 30 Jun 2013 21:23:42 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-la0-x231.google.com (mail-la0-x231.google.com [IPv6:2a00:1450:4010:c03::231]) by mx1.freebsd.org (Postfix) with ESMTP id B7D301C80 for ; Sun, 30 Jun 2013 21:23:41 +0000 (UTC) Received: by mail-la0-f49.google.com with SMTP id ea20so3675979lab.22 for ; Sun, 30 Jun 2013 14:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=TQMWS8ECRUcJQyJmDJBMoEpIwKfgv9oUTtUfbme5TxE=; b=rnYZaGr1fqhT+YYHSdyEYhCgyUYN/FwH76qop4iuwZvgpldD8ytecoBBzUDfKR4tWA WZfRrfhN5+IB1TqpMeVJBy90/R5lSrC4Rd3tGCrm4YE1vnoRv1emk2rHEZmE1rqWtegs PolbA3QkHtBfDTbtJqcQjXeXPCSTY4adUP/BIhe25C6UmlzkZngjBNrbiSL9v4wc4zXT 2W5Gd4tKaoL7gsFbCWhSUvoRrBhM0HmGfjcfEQb2CJt2fAnnhlN5zI9L8xr9L6jDby1O R5mu68E2GSuBT1kuIUw0vG/8mm8Td8SGxpPK4Y2lQykqS/2LBHqEd/AqwATiuhT4boe7 RAqg== X-Received: by 10.112.12.137 with SMTP id y9mr10341407lbb.91.1372627420684; Sun, 30 Jun 2013 14:23:40 -0700 (PDT) Received: from localhost ([178.150.115.244]) by mx.google.com with ESMTPSA id b8sm6188274lah.0.2013.06.30.14.23.38 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 30 Jun 2013 14:23:39 -0700 (PDT) Sender: Mikolaj Golub Date: Mon, 1 Jul 2013 00:23:35 +0300 From: Mikolaj Golub To: Mateusz Guzik Subject: Re: panic: Lock filedesc structure not share locked Message-ID: <20130630212334.GC3714@gmail.com> References: <20130630094150.00004a9c@unknown> <20130630082756.GA22492@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130630082756.GA22492@dft-labs.eu> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Alexander Leidinger , current@FreeBSD.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 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: Sun, 30 Jun 2013 21:23:42 -0000 On Sun, Jun 30, 2013 at 10:27:57AM +0200, Mateusz Guzik wrote: > On Sun, Jun 30, 2013 at 09:41:50AM +0200, Alexander Leidinger wrote: > > Hi, > > > > with head as of r252381 on amd64, I got the following panic after > > starting tmux and creating a 2nd terminal window inside tmux > > (ctrl- + c): > > ---snip--- > > panic: Lock filedesc structure not share locked @ /space/system/usr_src/sys/kern/kern_descrip.c:3448 > > > > cpuid = 2 > > KDB: stack backtrace: > > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffff839ee566d0 > > kdb_backtrace() at kdb_backtrace+0x39/frame 0xffffff839ee56780 > > vpanic() at vpanic+0x126/frame 0xffffff839ee567c0 > > panic() at panic+0x43/frame 0xffffff839ee56820 > > _sx_assert() at _sx_assert+0x134/frame 0xffffff839ee56830 > > _sx_sunlock() at _sx_sunlock+0x46/frame 0xffffff839ee56860 > > kern_proc_filedesc_out() at kern_proc_filedesc_out+0x420/frame 0xffffff839ee568e0 > > sysctl_kern_proc_filedesc() at sysctl_kern_proc_filedesc+0x66/frame 0xffffff839ee56950 > > sysctl_root() at sysctl_root+0x1bd/frame 0xffffff839ee569a0 > > userland_sysctl() at userland_sysctl+0x192/frame 0xffffff839ee56a40 > > sys___sysctl() at sys___sysctl+0x74/frame 0xffffff839ee56af0 > > amd64_syscall() at amd64_syscall+0x23c/frame 0xffffff839ee56bf0 > > Xfast_syscall() at Xfast_syscall+0xfb/frame 0xffffff839ee56bf0 > > ---snip--- > > > > Can you try this (only compile-tested): > diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c > index e760fe5..7aa17cd 100644 > --- a/sys/kern/kern_descrip.c > +++ b/sys/kern/kern_descrip.c > @@ -3272,6 +3272,8 @@ export_fd_to_sb(void *data, int type, int fd, int fflags, int refcnt, > if (efbuf->remainder < kif->kf_structsize) { > /* Terminate export. */ > efbuf->remainder = 0; > + if (!locked && efbuf->fdp != NULL) > + FILEDESC_SLOCK(efbuf->fdp); > return (0); > } > efbuf->remainder -= kif->kf_structsize; > Mateusz, thank you for spotting this lock leakage. Regardless if this is the root cause of the reported panic (it looks like it is), this fix should be definetly committed. Will you do this? -- Mikolaj Golub