Hello, I have written a small device driver for a static ram based disk. The code is - more or less - derived from Poul Henning Kamp's md device. It is written for FreeBSD 4.X.
This device is kld-loaded and runs without any problems with my 'standard' kernel configuration. As soon as I boot a kernel with some debug settings the driver crashes due to a failed assertion in my strategy routine. ******** Here are the diffs between my standard(-) and debug(+) kernel configuration: +options DDB +options DEBUG_LOCKS +options KBDIO_DEBUG +options SC_DEBUG_LEVEL=5 -options PANIC_REBOOT_WAIT_TIME=5 +options PANIC_REBOOT_WAIT_TIME=60 -options SC_DISABLE_DDBKEY +options SC_HISTORY_SIZE=1000 -device sio0 at isa? port IO_COM1 flags 0x10 irq 4 +device sio0 at isa? port IO_COM1 flags 0x90 irq 4 Some of the common options are HZ=400, DEVICE_POLLING, KTRACE, NO_SWAPPING, SOFTUPDATES, UFS_DIRHASH ******** Here is my debugging output: (kgdb) bt #1 0xc0153318 in panic (fmt=0xc0cabc80 "\"sram.c\", 362: sram_strategy: bp->b_dev==NULL") at ../../kern/kern_shutdown.c:593 #2 0xc0cab2e8 in sram_strategy (bp=0xc349bdc0) at sram.c:362 #3 0xc015ccad in diskstrategy (bp=0xc349bdc0) at ../../kern/subr_disk.c:251 #4 0xc0224952 in dsinit (dev=0xc0ca3e80, lp=0xc0c240d0, sspp=0xc0c240cc) at ../../kern/subr_diskmbr.c:191 #5 0xc015dbfa in dsopen (dev=0xc0ca3e80, mode=8192, flags=0, sspp=0xc0c240cc, lp=0xc0c240d0) at ../../kern/subr_diskslice.c:696 #6 0xc015cb36 in diskopen (dev=0xc0ca3e80, oflags=1, devtype=8192, p=0xc7bb5260) at ../../kern/subr_disk.c:196 #7 0xc018d72d in spec_open (ap=0xc8908dfc) at ../../miscfs/specfs/spec_vnops.c:193 #8 0xc018d62d in spec_vnoperate (ap=0xc8908dfc) at ../../miscfs/specfs/spec_vnops.c:119 #9 0xc01ccfb5 in ufs_vnoperatespec (ap=0xc8908dfc) at ../../ufs/ufs/ufs_vnops.c:2394 #10 0xc0189641 in vn_open (ndp=0xc8908ec8, fmode=1, cmode=385) at vnode_if.h:189 #11 0xc01854ec in open (p=0xc7bb5260, uap=0xc8908f80) at ../../kern/vfs_syscalls.c:1035 #12 0xc02193f9 in syscall2 (frame={tf_fs = 47, tf_es = 47, tf_ds = 47, tf_edi = 134543916, tf_esi = -1077936648, tf_ebp = -1077936736, tf_isp = -930050092, tf_ebx = 0, tf_edx = 134543904, tf_ecx = -13, tf_eax = 5, tf_trapno = 0, tf_err = 2, tf_eip = 671988064, tf_cs = 31, tf_eflags = 582, tf_esp = -1077937068, tf_ss = 47}) at ../../i386/i386/trap.c:1255 #13 0xc020c685 in Xint0x80_syscall () (kgdb) frame 2 (kgdb) p *bp $2 = {b_hash = {le_next = 0xc3504000, le_prev = 0xc0286c0c}, b_vnbufs = {tqe_next = 0x0, tqe_prev = 0x0}, b_freelist = {tqe_next = 0xc349bf18, tqe_prev = 0xc026e9e8}, b_act = {tqe_next = 0x0, tqe_prev = 0x0}, b_flags = 1122304, b_qindex = 0, b_xflags = 0 '\000', b_lock = {lk_interlock = {lock_data = 0}, lk_flags = 1024, lk_sharecount = 0, lk_waitcount = 0, lk_exclusivecount = 1, lk_prio = 20, lk_wmesg = 0xc0239afc "bufwait", lk_timo = 0, lk_lockholder = 134}, b_error = -1071408864, b_bufsize = -1071408848, b_runningbufspace = 286, b_bcount = 0, b_resid = 512, b_dev = 0x0, b_data = 0x200 <Address 0x200 out of bounds>, b_kvabase = 0x0, b_kvasize = -1060487424, b_lblkno = -1060470784, b_blkno = -1014542336, b_offset = 16384, b_iodone = 0, b_iodone_chain = 0xffffffff, b_vp = 0xffffffff, b_dirtyoff = 0, b_dirtyend = 0, b_rcred = 0x0, b_wcred = 0x0, b_pblkno = 0, b_saveaddr = 0x0, b_driver1 = 0x0, b_driver2 = 0x0, b_caller1 = 0x0, b_caller2 = 0x0, b_pager = { pg_spc = 0x0, pg_reqpage = 0}, b_cluster = {cluster_head = {tqh_first = 0x0, tqh_last = 0x0}, cluster_entry = {tqe_next = 0x0, tqe_prev = 0x0}}, b_pages = {0x0 <repeats 32 times>}, b_npages = 0, b_dep = {lh_first = 0x0}, b_chain = {parent = 0x0, count = 0}} ******** And here is the source of the beginning of my strategy routine: static void sram_strategy (struct buf * bp) { intrmask_t s; struct sram_softc * sc; ASSERT (bp != NULL, "sram_strategy: bp==NULL");/* #1 */ ASSERT (bp->b_dev != NULL, "sram_strategy: bp->b_dev==NULL");/* #2 */ sc = bp->b_dev->si_drv1; ASSERT (sc != NULL, "sram_strategy: bp->b_dev->si_drv1==NULL");/* #3 */ DPRINTF (9, "sram_strategy: (%p) %s %lx, %d, %ld, %p)\n", bp, devtoname (bp->b_dev), bp->b_flags, bp->b_blkno, bp->b_bcount / DEV_BSIZE, bp->b_data); s = splbio (); ... ASSERT #2 fails. Any idea? Thank you for any help, Norbert Koch _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"