Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Aug 2004 13:48:30 +1000
From:      Herbert Acker <hacker2004@damon.com>
To:        freebsd-hackers@freebsd.org
Subject:   sysctl_set panic
Message-ID:  <2061FF78-F8A5-11D8-BD8C-000A957C9058@damon.com>

next in thread | raw e-mail | index | archive | help
Hi.  I have been occasionally plagued by panics in KLD:

     at /usr/src/sys/i386/i386/trap.c:466
#6  0xc016c2dc in sysctl_register_oid (oidp=0x0)
     at /usr/src/sys/kern/kern_sysctl.c:92
#7  0xc016c841 in sysctl_register_set (lsp=0xcd5000a0)
     at /usr/src/sys/kern/kern_sysctl.c:391
#8  0xc0157847 in linker_file_register_sysctls (lf=0xcd4ea180)
     at /usr/src/sys/kern/kern_linker.c:224
#9  0xc01578fc in linker_load_file (

It bit me once several years ago, and then again today.
It croaks because it finds the sysctl_set symbol in the KLD but
the OIDs are zero.

I finally got pissed off enough and figured out what the problem is,
instead of using the dynamic-sysctls approach I adopted the other time.

Essentially, I have two KLDs.  One imports symbols from the other.
I have them in separate dirs, and have a -I ../dir0/ in the
Makefile of the KLD which imports the interface of the other KLD.

IE:

	dir0/has_interfaces_and_sysctls.c
	dir1/uses_interfaces_no_sysctls.c

	dir1/Makefile: CFLAGS += -I../dir0/


gensetdefs creates files to manage the .set sections.

The setdefs0.c includes setdefs.h, and the ../dir0/setdefs.h has some
sysctls, so it has the set definitions for those sysctls.

The second KLD has no sysctls.  The second KLD is being linked with
a setdefs0.o which is made using the ../dir0/setdefs.h.

Simple fix:  put "-I." in the CFLAGS prior to -I../dir0/.

Hopefully, this will be helpful to some others.

Damon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2061FF78-F8A5-11D8-BD8C-000A957C9058>