Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Sep 2011 11:53:24 -0700
From:      mdf@FreeBSD.org
To:        Charlie Martin <crmartin@sgi.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Understanding panic and exit in the kernel
Message-ID:  <CAMBSHm98=FykYxuWKEEvwA5fZsiDiUTtbCYhGEMig_gfyOa5cg@mail.gmail.com>
In-Reply-To: <4E67B323.8000602@sgi.com>
References:  <4E67B323.8000602@sgi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Sep 7, 2011 at 11:08 AM, Charlie Martin <crmartin@sgi.com> 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?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMBSHm98=FykYxuWKEEvwA5fZsiDiUTtbCYhGEMig_gfyOa5cg>