From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 9 14:47:15 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 78C4D37B405 for ; Wed, 9 Jul 2003 14:47:15 -0700 (PDT) Received: from mail.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by mx1.FreeBSD.org (Postfix) with ESMTP id 63C5143FAF for ; Wed, 9 Jul 2003 14:47:14 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 11207 invoked from network); 9 Jul 2003 21:47:13 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender )encrypted SMTP for ; 9 Jul 2003 21:47:13 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.9/8.12.9) with ESMTP id h69Ll8GI099976; Wed, 9 Jul 2003 17:47:09 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20030709150708.O30571@beagle.fokus.fraunhofer.de> Date: Wed, 09 Jul 2003 17:47:22 -0400 (EDT) From: John Baldwin To: harti@freebsd.org cc: hackers@freebsd.org Subject: RE: Race in kevent X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jul 2003 21:47:15 -0000 On 09-Jul-2003 Harti Brandt wrote: > > Hi, > > I just had a crash while typing ^C to a program that has a kevent timer > running. The crash was: > > callout_stop > callout_reset > filt_timerexpire > softclock > > and callout_stop was accessing freed memory (0xdeadc0e2). After looking > some time at the filt_timerdetach, callout_stop and softclock I think the > following happened: > > > Proc 1 Proc 2 > ------ ------ > filt_timerdetach softclock called > call with Giant locked > > lock_spin(callout_lock) > ... > call callout_stop which hangs on > lock_spin(callout_lock) > > sofclock finds the callout, > removes it from its queue and > clears PENDING > > unlock_spin(callout_lock) > lock(&Giant) blocks > > callout_stop finds the callout to > be not pending and returns > > filt_timerdetach frees the callout > > ... > > unlock(&Giant) > softclock continues and calls > the (stopped) callout > > KABOOM because the pointer used > by filt_timerexpire is gone This is becoming a common race unfortunately. :( See the hacks in msleep() that use TDF_TIMEOUT in coooperationg with endtsleep() and the recent commit to the realtimer callout code for ways to work around this race. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/