From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 7 18:53:25 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C9EEF106566B for ; Wed, 7 Sep 2011 18:53:25 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-qw0-f44.google.com (mail-qw0-f44.google.com [209.85.216.44]) by mx1.freebsd.org (Postfix) with ESMTP id 87EDE8FC17 for ; Wed, 7 Sep 2011 18:53:25 +0000 (UTC) Received: by qwg2 with SMTP id 2so723785qwg.17 for ; Wed, 07 Sep 2011 11:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; 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 :content-transfer-encoding; bh=YTOT8+7sooRt5TcbAfNq1VNfjJ2v7Nma69PHPZRdOPo=; b=YYCtQfLjM88pMSIZBCveQwSoaBE8gGv/44tnu6zqvCTvc1NUc1Yfl7BAzZkOnULgPt RTYUla48vfPN0ibCzUbqEK6XeMza/VL/i08sq5fyEuXqWjyxjNUD52wK9OIBF0oEDDKj yUjC7G+lwppuz6acQ7bsuTU9lN9fiDhDpzV44= MIME-Version: 1.0 Received: by 10.229.87.137 with SMTP id w9mr5030605qcl.284.1315421604813; Wed, 07 Sep 2011 11:53:24 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.229.190.194 with HTTP; Wed, 7 Sep 2011 11:53:24 -0700 (PDT) In-Reply-To: <4E67B323.8000602@sgi.com> References: <4E67B323.8000602@sgi.com> Date: Wed, 7 Sep 2011 11:53:24 -0700 X-Google-Sender-Auth: WgzFHkKRw642JXc5IKpMF0XdB8g Message-ID: From: mdf@FreeBSD.org To: Charlie Martin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: Understanding panic and exit in the kernel X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Sep 2011 18:53:25 -0000 On Wed, Sep 7, 2011 at 11:08 AM, Charlie Martin wrote: > I'm still pursuing a FreeBSD bug in "7.2-PRERELEASE FreeBSD" -- and yes, = we > know this is wildly out of date, but it's not feasible to upgrade right n= ow > -- and while trying to backport a fix suggested here > http://permalink.gmane.org/gmane.os.freebsd.current/134266 I got a situat= ion > where the panic calls in one of =A0these two macros from sys/queue.h > > #define =A0 =A0QMD_LIST_CHECK_NEXT(elm, field) do { =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0\ > =A0 =A0if (LIST_NEXT((elm), field) !=3D NULL && =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0\ > =A0 =A0 =A0 =A0LIST_NEXT((elm), field)->field.le_prev !=3D =A0 =A0 =A0 = =A0 =A0 =A0\ > &((elm)->field.le_next)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ > =A0 =A0 =A0 =A0 =A0 =A0 panic("Bad link elm %p next->prev !=3D elm", (elm= )); =A0 =A0\ > } while (0) > > #define =A0 =A0QMD_LIST_CHECK_PREV(elm, field) do { =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0\ > =A0 =A0if (*(elm)->field.le_prev !=3D (elm)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0\ > =A0 =A0 =A0 =A0panic("Bad link elm %p prev->next !=3D elm", (elm)); =A0 = =A0\ > } while (0) > > print the message, but *don't* then proceed to drop to the debugger -- > instead the system hangs, with the CPU running but I had no luck getting = its > attention to force it to the debugger. > > I'm not clear just what could be causing the hangup. > > For my immediate purposes, I'd be happy with any way in which I could > brutally kill the kernel and force it to the debugger, say by replacing t= he > panic call with a printf followed by "1/0;". =A0But I'm a little confused= by > the panic.c code -- it prints the arguments using a var_args, and then ca= lls > "exit(1);' What file are you looking in? The kernel panic() is in sys/kern/kern_shutdown.c, not sys/boot/common/panic.c. It will optionally call kdb_enter_why() and then boot(). Do you have the debug.debugger_on_panic sysctl set to 1? Thanks, matthew > So my questions: > > (1) will my brutal method actually force what I want or am I > misunderstanding something > (2) *which* of the several implementations of "int exit(int)" or similar = is > the one called in the FreeBSD kernel? > (3) and how then does exit work?