Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Jan 2008 10:21:02 -0500
From:      Joe Marcus Clarke <marcus@FreeBSD.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        FreeBSD Current <freebsd-current@FreeBSD.org>
Subject:   Re: page fault panic in scioctl and console-kit-daemon
Message-ID:  <1201188062.24613.1.camel@shumai.marcuscom.com>
In-Reply-To: <20080124124213.GD57756@deviant.kiev.zoral.com.ua>
References:  <4792C32C.5010205@gmail.com> <20080122133835.GT57756@deviant.kiev.zoral.com.ua> <4796356D.9080809@gmail.com> <20080123051648.GV57756@deviant.kiev.zoral.com.ua> <479796E1.4000500@gmail.com> <1201118159.38742.17.camel@shumai.marcuscom.com> <20080123211149.GA57756@deviant.kiev.zoral.com.ua> <1201123933.62127.9.camel@shumai.marcuscom.com> <20080124124213.GD57756@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-MG3FTPiDJWmrIKzquvlA
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable


On Thu, 2008-01-24 at 14:42 +0200, Kostik Belousov wrote:
> On Wed, Jan 23, 2008 at 04:32:13PM -0500, Joe Marcus Clarke wrote:
> >=20
> > On Wed, 2008-01-23 at 23:11 +0200, Kostik Belousov wrote:
> > > On Wed, Jan 23, 2008 at 02:55:59PM -0500, Joe Marcus Clarke wrote:
> > > >=20
> > > > On Wed, 2008-01-23 at 20:34 +0100, Pawel Worach wrote:
> > > > > Kostik Belousov wrote:
> > > > > > On Tue, Jan 22, 2008 at 07:26:53PM +0100, Pawel Worach wrote:
> > > > > >> Kostik Belousov wrote:
> > > > > >>> On Sun, Jan 20, 2008 at 04:42:36AM +0100, Pawel Worach wrote:
> > > > > >>>> Hi,
> > > > > >>>>
> > > > > >>>> While starting console-kit-daemon (sysutils/consolekit 0.2.3=
) during=20
> > > > > >>>> boot or in single-user mode the system panics. If I start it=
 post-boot=20
> > > > > >>>> it runs fine. This is on 8.0-CURRENT from about 12 hours ago=
, another=20
> > > > > >>>> user also reported the same on RELENG_7. Any other informati=
on I can=20
> > > > > >>>> provide ?
> > > > > >>>>
> > > > > >>>> Fatal trap 12: page fault while in kernel mode
> > > > > >>>> fault virtual address	=3D 0x4
> > > > > >>>> fault code		=3D supervisor read, page not present
> > > > > >>>> instruction pointer	=3D 0x20:0xc04d2ab4
> > > > > >>>> stack pointer	        =3D 0x28:0xe6499b18
> > > > > >>>> frame pointer	        =3D 0x28:0xe6499b80
> > > > > >>>> code segment		=3D base 0x0, limit 0xfffff, type 0x1b
> > > > > >>>> 			=3D DPL 0, pres 1, def32 1, gran 1
> > > > > >>>> processor eflags	=3D interrupt enabled, resume, IOPL =3D 0
> > > > > >>>> current process		=3D 134 (console-kit-daemon)
> > > > > >>>> Physical memory: 1014 MB
> > > > > >>>> Dumping 43 MB: 28 12
> > > > > >>>>
> > > > > >>>> #8  0xc07a34a2 in trap (frame=3D0xe6499ad8) at=20
> > > > > >>>> /usr/src/sys/i386/i386/trap.c:489
> > > > > >>>> #9  0xc079183b in calltrap () at /usr/src/sys/i386/i386/exce=
ption.s:146
> > > > > >>>> #10 0xc04d2ab4 in scioctl (dev=3D0xc3b20d00, cmd=3D537163270=
,
> > > > > >>>>    data=3D0xe6499c70 "\002", flag=3D1, td=3D0xc3d3c880)
> > > > > >>>>    at /usr/src/sys/dev/syscons/syscons.c:1073
> > > > > >>>> #11 0xc051ed1a in giant_ioctl (dev=3D0xc3b20d00, cmd=3D53716=
3270,
> > > > > >>>>    data=3D0xe6499c70 "\002", fflag=3D1, td=3D0xc3d3c880)
> > > > > >>>>    at /usr/src/sys/kern/kern_conf.c:349
> > > > > >>>> #12 0xc0598194 in cnioctl (dev=3D0xc3b20d00, cmd=3D537163270=
,
> > > > > >>>>    data=3D0xe6499c70 "\002", flag=3D1, td=3D0xc3d3c880)
> > > > > >>>> ---Type <return> to continue, or q <return> to quit---
> > > > > >>>>    at /usr/src/sys/kern/tty_cons.c:521
> > > > > >>> Unless the virtual screen is opened, the screen state scr_sta=
t structure
> > > > > >>> is not allocated. The following patch would fix the panic, bu=
t I do not
> > > > > >>> know how the console-kit would react to the ENXIO from the
> > > > > >>> VT_WAITACTIVE ioctl. Please, test it.
> > > > > >> Thanks! The patch works.
> > > > > >=20
> > > > > > To clarify: do you see any problems with the console-kit after =
the patch ?
> > > > > > In particular, can you verify that the program functions correc=
tly, esp.
> > > > > > on the virtual terminals 1, 2 ... , whatever this means ?
> > > > >=20
> > > > > The panic is of course gone, while chatting a bit with Marcus (CC=
d) it=20
> > > > > looks like console-kit does not do any error handling at all. I'v=
e not=20
> > > > > looked at what c-k does so maybe Marcus can answer the question b=
etter.
> > > >=20
> > > > It tries to install a wait thread on each available VT.  That threa=
d
> > > > sets the WAITACTIVE ioctl, and waits for its VT to become active.  =
When
> > > > it does, it sets the CK active VT accordingly, and reattaches the w=
ait.
> > > >=20
> > > > When an error occurs in the ioctl, no wait is attached, and CK will=
 not
> > > > know when a particular VT becomes active.  This will essentially cr=
ipple
> > > > CK (assuming the VT really does become available at a later point).=
 =20
> > > >=20
> > > > Now, admittedly, there is no error correction in CK for this situat=
ion.
> > > > It would be trivial to add something that periodically attempts to
> > > > reestablish a failed wait.  However, I am very curious why only a f=
ew
> > > > users are seeing this panic (me excluded on two different machines)=
.  It
> > > > seems to me that the scp should be initialized when sc_attach_unit(=
) is
> > > > called during device probing.  I don't see anything special in init=
(8)'s
> > > > code that would cause these VT devices to become initialized.  I wo=
uld
> > > > assume that if one can open(2) them, then they should be available =
for
> > > > ioctls?
> > >=20
> > > From my reading of the code, scp would be non-NULL after the first op=
en
> > > of the corresponding /dev/ttyvX. sc_attach_unit() creates the scp for
> > > the console and the consolectl devices.
> > >=20
> > > VT_WAITACTIVE ioctl is performed on arbitrary syscons /dev node, and
> > > can wait for any other screens, in particular, the screens that are
> > > not opened at the moment (the reason for the reported panic).
> >=20
> > Right, and this is where I was confused.  I had thought from an old
> > reading of the CK code that CK opened each ttyvX device to perform the
> > ioctl.  It does not.  Instead, it opens /dev/console, and performs the
> > ioctl for each ttyvX on that fd.  That does explain the panic, but not
> > exactly why I did not see it.  I'm guessing a race condition, but I
> > can't be sure.
> >=20
> > >=20
> > > The patch I posted may be improved by making the VT_WAITACTIVE ioctl
> > > to wait for the scp being allocated, and only then for the screen to =
be
> > > switched too. Please, test.
> >=20
> > I really appreciate your attention to this.  Funny thing is, CK 0.2.4
> > was just released, and it is no longer started out of rc.d.  I've also
> > added error correcting in the CK code path.  The problem may disappear
> > depending on when CK is executed out of D-BUS.  However, it would be
> > good to prevent this in the kernel.  Pawel said he would try and test
> > this patch.
>=20
> This must be fixed in the kernel, at least because it allows any console
> user to panic the system. The question I have to you is what approach sha=
ll
> we use:

Fully agree.

> - return the ENXIO (1)
> - do the wait for the open, then wait for the switch (2)
>=20
> I would prefer (1), both due to putting the decision to the userspace, an=
d
> to not have the algorithm that could be implemented in userspace, in the
> kernel. On the other hand, as the maintainer of the one of the major API
> consumer there, you may have the different opinion, that is crusial.

I've already added code to CK to handle ENXIO (or any error) in
userspace, so I'm okay with option 1.

Joe

--=20
Joe Marcus Clarke
FreeBSD GNOME Team      ::      gnome@FreeBSD.org
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome

--=-MG3FTPiDJWmrIKzquvlA
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (FreeBSD)

iEYEABECAAYFAkeYrN0ACgkQb2iPiv4Uz4cGnwCcDhSsKg2TdNDO4MabQMPTbW4G
09YAni7ZkbDxKPmik9Vju7X7FrTviOR2
=wXHU
-----END PGP SIGNATURE-----

--=-MG3FTPiDJWmrIKzquvlA--




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