Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Sep 2001 18:36:58 +0200 (CEST)
From:      Maxime Henrion <mux@qualys.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/30592: [PATCH] panic: static sysctl oid too high: 684 - when unloading snd_es137x.ko
Message-ID:  <200109151636.f8FGawe01383@noos.fr>

next in thread | raw e-mail | index | archive | help

>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:
<organization of PR author (multiple lines)>
>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109151636.f8FGawe01383>