From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 20 19:00:41 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B1A0116A4CE for ; Wed, 20 Apr 2005 19:00:41 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D4C1943D49 for ; Wed, 20 Apr 2005 19:00:40 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j3KJ0e7L020588 for ; Wed, 20 Apr 2005 19:00:40 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j3KJ0evi020549; Wed, 20 Apr 2005 19:00:40 GMT (envelope-from gnats) Resent-Date: Wed, 20 Apr 2005 19:00:40 GMT Resent-Message-Id: <200504201900.j3KJ0evi020549@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Steve Sears Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 781ED16A4CE for ; Wed, 20 Apr 2005 18:58:38 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59E7943D3F for ; Wed, 20 Apr 2005 18:58:38 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j3KIwcou023410 for ; Wed, 20 Apr 2005 18:58:38 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j3KIwciS023409; Wed, 20 Apr 2005 18:58:38 GMT (envelope-from nobody) Message-Id: <200504201858.j3KIwciS023409@www.freebsd.org> Date: Wed, 20 Apr 2005 18:58:38 GMT From: Steve Sears To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: kern/80166: Debugger SMP race panic X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2005 19:00:41 -0000 >Number: 80166 >Category: kern >Synopsis: Debugger SMP race panic >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 20 19:00:39 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Steve Sears >Release: 5.3-RELEASE >Organization: >Environment: FreeBSD sjs-linux 5.3-RELEASE FreeBSD 5.3-RELEASE #19: Mon Apr 18 11:28:21 EDT 2005 root@sjs-linux:/usr/src/sys-sjs/i386/compile/SJSKERN i386 >Description: panic: mi_switch: did not reenter debugger This panic happens often when setting a breakpoint and then hitting it a few times. I think I see the problem. The bsd code in kern/subr_kdb.c does this: #ifdef SMP if (did_stop_cpus) restart_cpus(stopped_cpus); #endif kdb_active--; The panic is this (mi_switch): /* * Don't perform context switches from the debugger. */ if (kdb_active) { mtx_unlock_spin(&sched_lock); kdb_backtrace(); kdb_reenter(); panic("%s: did not reenter debugger", __func__); } It's an mp-race. It restarts the other CPU's before decrementing kdb_active. If the other CPU races into mi_switch first, a panic is guaranteed. >How-To-Repeat: Hit the same breakpoint several times on an SMP box. >Fix: Decrement kdb_active before restarting cpus. >Release-Note: >Audit-Trail: >Unformatted: