From owner-freebsd-current@FreeBSD.ORG Wed Jul 7 12:01:14 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF36A1065670 for ; Wed, 7 Jul 2010 12:01:14 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 68A3B8FC32 for ; Wed, 7 Jul 2010 12:01:14 +0000 (UTC) Received: by qyk7 with SMTP id 7so3005109qyk.13 for ; Wed, 07 Jul 2010 05:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=4XNcbmnRBryiCUlzZJEF9MgYyFVSiKzj5t472Numdk0=; b=rtyVPhthL5ZtPtF5AmdSoIsPegHgVgZPO8b2HI/aydpjYFrECcCODFSMqPptg2/A/B SxzWAoIfVKAmwD3oyaIz8kp7SnxnhfNQkAwE+hAgSIz6cX3+wFq+K+xlERz0whZILGkC VykIzq47cQxCpacIij0KINMrRqDfRSGsFS54Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=xgvO/8wstfPc/TCVz6vzdGJH/RMYZwaiae39gn7hX6P/lBlrsg2J8OkjyNNCTTPplF HsQ3VrwNurRxviHDyaj1b0FOhE4vkRbo3RXgWBAT7XcoQgPXG5P8UjWXjWBn15Xf55Y8 ay+k87XGBTbNukjQh6TikNN8Wl0I00i33MUA4= MIME-Version: 1.0 Received: by 10.224.28.76 with SMTP id l12mr3479847qac.24.1278504061482; Wed, 07 Jul 2010 05:01:01 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.229.17.3 with HTTP; Wed, 7 Jul 2010 05:01:01 -0700 (PDT) In-Reply-To: <269478215.24.1277969553870.JavaMail.root@sage.daemoninthecloset.org> References: <744734406.21.1277969273426.JavaMail.root@sage.daemoninthecloset.org> <269478215.24.1277969553870.JavaMail.root@sage.daemoninthecloset.org> Date: Wed, 7 Jul 2010 14:01:01 +0200 X-Google-Sender-Auth: lnii-HrBQr0sKiWeRIpeovJO148 Message-ID: From: Attilio Rao To: Bryan Venteicher Content-Type: text/plain; charset=UTF-8 Cc: freebsd-current@freebsd.org Subject: Re: deadlkres() panic X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Wed, 07 Jul 2010 12:01:14 -0000 2010/7/1 Bryan Venteicher : > On a recent -current, I got the following panic from deadlkres: > > Assertion wchan != NULL failed at /usr/src-nfs/sys/kern/subr_sleepqueue.c:680 > > Tracing pid 0 tid 100058 td 0xffffff00024bf7a0 > kdb_enter() at kdb_enter+0x3d > panic() at panic+0x176 > sleepq_type() at sleepq_type+0x56 > deadlkres() at deadlkres+0x224 > fork_exit() at fork_exit+0x12a > fork_trampoline() at fork_trampoline+0xe > --- trap 0, rip = 0, rsp = 0xffffff8074976d30, rbp = 0 --- > (Hand transcribed, doadump() hung) > > deadlkres() came across a TD_IS_SLEEPING()'ing thread that was not a > sleepqueue (ie, td->td_wchan == NULL). > > I don't think this is an invalid state for thread to be in: After adding itself > to a sleepq and setting a timeout, the thread calls sleepq_timedwait_sig(). > sleepq_catch_signals() determines there is a signal pending so it removes the > thread from the sleepq via sleepq_resume_thread(). Returning to > sleepq_timedwait_sig(), in the call to sleepq_check_timeout(), the thread is > unable to cancel the timeout because it is already firing (likely waiting on > thread_lock()). So the thread calls TD_SET_SLEEPING() followed by mi_switch(). > deadlkres() then picks up thread_lock(), finding td is TD_IS_SLEEPING() && > !TD_ON_SLEEPQ(). > > The attached patch takes care of the panic for me. I think that your analysis and patch are both fine and are committed, along with a small cleanup, as r209761. Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein