From owner-freebsd-bugs Sat Sep 15 9:40:14 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 5343E37B408 for ; Sat, 15 Sep 2001 09:40:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8FGe1T21468; Sat, 15 Sep 2001 09:40:01 -0700 (PDT) (envelope-from gnats) Received: from noos.fr (e109.dhcp212-198-25.noos.fr [212.198.25.109]) by hub.freebsd.org (Postfix) with ESMTP id 7402337B40F for ; Sat, 15 Sep 2001 09:37:00 -0700 (PDT) Received: (from mux@localhost) by noos.fr (8.11.6/8.11.4) id f8FGawe01383 for FreeBSD-gnats-submit@freebsd.org; Sat, 15 Sep 2001 18:36:58 +0200 (CEST) (envelope-from mux) Message-Id: <200109151636.f8FGawe01383@noos.fr> Date: Sat, 15 Sep 2001 18:36:58 +0200 (CEST) From: Maxime Henrion To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/30592: [PATCH] panic: static sysctl oid too high: 684 - when unloading snd_es137x.ko Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 30592 >Category: kern >Synopsis: [PATCH] panic: static sysctl oid too high: 684 - when unloading snd_es137x.ko >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Sep 15 09:40:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Maxime Henrion >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD nebula.cybercable.fr 5.0-CURRENT FreeBSD 5.0-CURRENT #103: Sat Sep 15 18:03:06 CEST 2001 mux@nebula.cybercable.fr:/usr/src/sys/i386/compile/NEBULA i386 >Description: panic: static sysctl oid too high: 684 (kgdb) bt [...] #10 0xc0189716 in sysctl_register_oid (oidp=0xc19710c0) at ../../../kern/kern_sysctl.c:127 #11 0xc01897f8 in sysctl_ctx_free (clist=0xc0cd3c68) at ../../../kern/kern_sysctl.c:192 (kgdb) list 191 while (e1 != NULL) { 192 sysctl_register_oid(e1->entry); 193 e1 = TAILQ_PREV(e1, sysctl_ctx_list, link); 194 } (kgdb) print *e1->entry $1 = {oid_parent = 0xc033d040, oid_link = {sle_next = 0x0}, oid_number = 684, oid_kind = -2113929215, oid_arg1 = 0xc0cd8540, oid_arg2 = 0, oid_name = 0xc0cd8550 "pcm0", oid_handler = 0, oid_fmt = 0xc0338b3d "N", oid_refcnt = 1} (kgdb) printf "%x\n",e1->entry->oid_kind 82000001 ^ CTLFLAG_DYN From src/sys/kern/kern_sysctl.c in sysctl_ctx_free() : /* * First perform a "dry run" to check if it's ok to remove oids. * XXX FIXME * XXX This algorithm is a hack. But I don't know any * XXX better solution for now... */ It appears in the comments of sysctl_ctx_free() that this function is a hack. It seems it sometimes has to re-register an oid, and sometimes tries to re-register dynamic sysctls. In that case it doesn't change the oid_number of the oid, and just call sysctl_register_oid() which panics because it is too high. I'm not able to properly fix this function right now, because I don't understand the reasons of this hack, however I can provide a patch that sets the oid_number to OID_AUTO if it was greater or equal to CTL_AUTO_START. With this patch applied, I can now happily load and unload my sound modules several times. >How-To-Repeat: # kldunload snd_es137x >Fix: Note: It would perhaps be better to test oid_kind against CTLFLAG_DYN instead of looking at the oid_number. --- patch begins here --- --- /usr/src/sys/kern/kern_sysctl.c Fri Sep 14 21:01:08 2001 +++ kern_sysctl.c Sat Sep 15 18:00:30 2001 @@ -189,6 +189,8 @@ else e1 = TAILQ_LAST(clist, sysctl_ctx_list); while (e1 != NULL) { + if (e1->entry->oid_number >= CTL_AUTO_START) + e1->entry->oid_number = OID_AUTO; sysctl_register_oid(e1->entry); e1 = TAILQ_PREV(e1, sysctl_ctx_list, link); } --- patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message