From owner-freebsd-current@FreeBSD.ORG Fri Aug 31 19:13:42 2007 Return-Path: Delivered-To: Current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 995C216A417 for ; Fri, 31 Aug 2007 19:13:42 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from creme-brulee.marcuscom.com (penna-pt.tunnel.tserv1.fmt.ipv6.he.net [IPv6:2001:470:1f00:ffff::1279]) by mx1.freebsd.org (Postfix) with ESMTP id 5DFFD13C4A5 for ; Fri, 31 Aug 2007 19:13:42 +0000 (UTC) (envelope-from marcus@FreeBSD.org) Received: from [IPv6:2001:470:1f00:2464::4] (shumai.marcuscom.com [IPv6:2001:470:1f00:2464::4]) by creme-brulee.marcuscom.com (8.14.1/8.14.1) with ESMTP id l7VJFF4k098879 for ; Fri, 31 Aug 2007 15:15:15 -0400 (EDT) (envelope-from marcus@FreeBSD.org) From: Joe Marcus Clarke To: Current@FreeBSD.org In-Reply-To: <1188430624.1077.21.camel@shumai.marcuscom.com> References: <1188430624.1077.21.camel@shumai.marcuscom.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-eWrMAA/vYwkugKaQIHmt" Organization: FreeBSD, Inc. Date: Fri, 31 Aug 2007 15:13:36 -0400 Message-Id: <1188587616.11028.31.camel@shumai.marcuscom.com> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 FreeBSD GNOME Team Port X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on creme-brulee.marcuscom.com Cc: Subject: Re: VT_WAITACTIVE leads to unkillable processes 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: Fri, 31 Aug 2007 19:13:42 -0000 --=-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--