Date: Fri, 31 Aug 2007 15:13:36 -0400 From: Joe Marcus Clarke <marcus@FreeBSD.org> To: Current@FreeBSD.org Subject: Re: VT_WAITACTIVE leads to unkillable processes Message-ID: <1188587616.11028.31.camel@shumai.marcuscom.com> In-Reply-To: <1188430624.1077.21.camel@shumai.marcuscom.com> References: <1188430624.1077.21.camel@shumai.marcuscom.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-eWrMAA/vYwkugKaQIHmt Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2007-08-29 at 19:37 -0400, Joe Marcus Clarke wrote: > flz and I are working on a port of ConsoleKit to FreeBSD. ConsoleKit is > a framework for tracking local users (i.e. users sitting at a machine) > and their sessions. =20 >=20 > Since it tracks local users and their consoles, it makes generous use of > consio. One of the things it does is get a list of the total number of > available consoles (i.e. vtys) and starts a thread for each one to check > when the console becomes active. To do this, each thread invokes the > VT_WAITACTIVE ioctl, and sits in waitvt until its vty becomes active. > This works quite well. >=20 > Where things break down is when the ConsoleKit daemon is stopped. When > the daemon receives a signal, it immediately jumps to 100% of the CPU > and claims to be in waitvt. It will not die unless you reboot the > machine, or get lucky with the debugger. >=20 > Below is a link to a small sample program that will reproduce this > behavior. Simply compile the program, and run it from a vty other than > 3 (ttyv2). Then try a control+C, and the problem will appear instantly. >=20 > I've been testing 7.0-CURRENT #104: Thu Aug 16 16:54:28 EDT 2007 with > ULE, but I have a report from flz that the same loop is observed on > -STABLE with 4BSD. When I ran the test on -STABLE, my box immediately > panicked, but I did not have dumps setup. >=20 > Yes, this is a, "doctor it hurts when I do this" kind of thing; however, > since this does not happen on Linux, I'm wondering if the kernel portion > of the VT_WAITACTIVE ioctl can be modified not to cause this tight loop > (or panic)? >=20 > WARNING: This running this program will either cause instance on mostly > unstoppable CPU load on your machine or panic it. >=20 > http://www.marcuscom.com/downloads/vty.c >=20 > gcc -o vty vty.c > (switch to ttyv0) > ./vty=20 I did some more research into the kernel code, and I found I can interrupt and terminate the process if I register signal handlers (simple do-nothing signal handlers) because they populate ps_sigintr. When ps_sigintr contains the right signal, tsleep() will return EINTR instead of ERESTART. This seems to be working fine. Joe --=20 Joe Marcus Clarke FreeBSD GNOME Team :: gnome@FreeBSD.org FreeNode / #freebsd-gnome http://www.FreeBSD.org/gnome --=-eWrMAA/vYwkugKaQIHmt Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQBG2Ghfb2iPiv4Uz4cRAui9AKCN7sxr44hAFSczBBDe8iA72LRWBgCgnzoV NEHODJDf5o+JXtdcLWnkUfs= =eUvE -----END PGP SIGNATURE----- --=-eWrMAA/vYwkugKaQIHmt--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1188587616.11028.31.camel>