vn_fullpath: 0xc85e24a0 is not locked but should be

Robert Watson rwatson at FreeBSD.org
Thu Dec 11 20:15:08 PST 2003


On Fri, 12 Dec 2003, Jun Kuriyama wrote:

> As of today's -current with SCHED_4BSD.  I saved "ps" output on ddb, so
> I can place it somewhere if somebody wants.
> 
> # Why I got so many panics?  :-(

Ah, you're still runing with the VFS lock debugging :-).  Indeed, it looks
like a vn_lock() and unlock of p->p_textvp is missing in
procfs_doprocfile(), even though that likely would violate the VFS lock
order.  The attached (untested) patch might well fix it, but might not be
right -- I'm not sure that curthread holds a valid reference to
p->p_textvp that can't evaporate during these operations.  I'm not sure
the proc reference stuff protects us properly here, but John would know
(CC'd). 

Index: procfs.c
===================================================================
RCS file: /home/ncvs/src/sys/fs/procfs/procfs.c,v
retrieving revision 1.9
diff -u -r1.9 procfs.c
--- procfs.c	17 Apr 2003 22:12:12 -0000	1.9
+++ procfs.c	12 Dec 2003 04:13:10 -0000
@@ -70,7 +70,9 @@
 	char *fullpath = "unknown";
 	char *freepath = NULL;
 
+	vn_lock(p->p_textvp, LK_EXCLUSIVE | LK_RETRY, td);
 	vn_fullpath(td, p->p_textvp, &fullpath, &freepath);
+	VOP_UNLOCK(p->p_textvp, 0, td);
 	sbuf_printf(sb, "%s", fullpath);
 	if (freepath)
 		free(freepath, M_TEMP);


Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Senior Research Scientist, McAfee Research

> 
> ----- console
> vn_fullpath: 0xc85e24a0 is not locked but should be
> Debugger("Lock violation.
> ")
> Stopped at      Debugger+0x55:  xchgl   %ebx,in_Debugger.0
> db> trace
> Debugger(c0739a77,c0739010,c85e24a0,c0739ab8,ece05710) at Debugger+0x55
> vfs_badlock(c0739ab8,c0739010,c85e24a0,c07a38c0,c85e24a0) at vfs_badlock+0x45
> assert_vop_locked(c85e24a0,c0739010,2,246,c93e0200) at assert_vop_locked+0x62
> vn_fullpath(c8e12500,c85e24a0,ece05754,ece05758,c0750da7) at vn_fullpath+0x81
> procfs_doprocfile(c8e12500,c9c7054c,c8295e00,ece0577c,0) at procfs_doprocfile+0x3a
> pfs_readlink(ece05bd0,c0739563,c0739548,a6,c8e12500) at pfs_readlink+0x11b
> namei(ece05c28,c07b4bb8,c07b4b40,c07b2d00,607) at namei+0x43a
> stat(c8e12500,ece05d14,c0752fc5,3ee,2) at stat+0x52
> syscall(2f,2f,2f,bfbfe270,bfbfe350) at syscall+0x2c0
> Xint0x80_syscall() at Xint0x80_syscall+0x1d
> --- syscall (188, FreeBSD ELF32, stat), eip = 0x280cb47f, esp = 0xbfbfe24c, ebp = 0xbfbfe7c8 ---
> db> show locks
> exclusive sleep mutex Giant r = 0 (0xc07ae560) locked @ i386/i386/trap.c:1000
> db> show lockedvnods
> Locked vnodes
> 0xc9d1e5c8: tag pseudofs, type VLNK, usecount 1, writecount 0, refcount 0, lock type pseudofs: EXCL (count 1) by thread 0xc8e12500 (pid:19220)
> 
> db> panic
> panic: from debugger
> cpuid = 1; 
> boot() called on cpu#1
>     ACPI-0265: *** Error: Hardware never changed modes
> 
> syncing disks, buffers remaining... VOP_LOCK: 0xc85e2250 is not locked but should be
> VOP_FSYNC: 0xc85e2250 is not locked but should be
> ffs_update: 0xc85e2250 is not locked but should be
> VOP_FSYNC: 0xc85e2250 is not locked but should be
> VOP_UNLOCK: 0xc85e2250 is not locked but should be
> VOP_LOCK: 0xc85e2128 is not locked but should be
> VOP_FSYNC: 0xc85e2128 is not locked but should be
> ffs_update: 0xc85e2128 is not locked but should be
> VOP_FSYNC: 0xc85e2128 is not locked but should be
> VOP_UNLOCK: 0xc85e2128 is not locked but should be
> VOP_LOCK: 0xc85e2000 is not locked but should be
> VOP_FSYNC: 0xc85e2000 is not locked but should be
> ffs_update: 0xc85e2000 is not locked but should be
> VOP_FSYNC: 0xc85e2000 is not locked but should be
> VOP_UNLOCK: 0xc85e2000 is not locked but should be
> VOP_LOCK: 0xc85e36f0 is not locked but should be
> VOP_FSYNC: 0xc85e36f0 is not locked but should be
> ffs_update: 0xc85e36f0 is not locked but should be
> VOP_FSYNC: 0xc85e36f0 is not locked but should be
> VOP_UNLOCK: 0xc85e36f0 is not locked but should be
> VOP_LOCK: 0xc8648378 is not locked but should be
> VOP_FSYNC: 0xc8648378 is not locked but should be
> ffs_update: 0xc8648378 is not locked but should be
> VOP_FSYNC: 0xc8648378 is not locked but should be
> VOP_UNLOCK: 0xc8648378 is not locked but should be
> VOP_LOCK: 0xc8713000 is not locked but should be
> VOP_FSYNC: 0xc8713000 is not locked but should be
> ffs_update: 0xc8713000 is not locked but should be
> VOP_FSYNC: 0xc8713000 is not locked but should be
> VOP_UNLOCK: 0xc8713000 is not locked but should be
> VOP_LOCK: 0xc8737250 is not locked but should be
> VOP_FSYNC: 0xc8737250 is not locked but should be
> ffs_update: 0xc8737250 is not locked but should be
> VOP_FSYNC: 0xc8737250 is not locked but should be
> VOP_UNLOCK: 0xc8737250 is not locked but should be
> VOP_LOCK: 0xc8765378 is not locked but should be
> VOP_FSYNC: 0xc8765378 is not locked but should be
> ffs_update: 0xc8765378 is not locked but should be
> VOP_FSYNC: 0xc8765378 is not locked but should be
> VOP_UNLOCK: 0xc8765378 is not locked but should be
> VOP_LOCK: 0xc8765250 is not locked but should be
> VOP_FSYNC: 0xc8765250 is not locked but should be
> ffs_update: 0xc8765250 is not locked but should be
> VOP_FSYNC: 0xc8765250 is not locked but should be
> VOP_UNLOCK: 0xc8765250 is not locked but should be
> VOP_LOCK: 0xc87ba250 is not locked but should be
> VOP_FSYNC: 0xc87ba250 is not locked but should be
> ffs_update: 0xc87ba250 is not locked but should be
> VOP_FSYNC: 0xc87ba250 is not locked but should be
> VOP_UNLOCK: 0xc87ba250 is not locked but should be
> panic: pmap_invalidate_range: interrupts disabled
> cpuid = 1; 
> boot() called on cpu#1
>     ACPI-0265: *** Error: Hardware never changed modes
> Uptime: 46m47s
> Dumping 2047 MB
> ...
> -----
> 
> 
> -- 
> Jun Kuriyama <kuriyama at imgsrc.co.jp> // IMG SRC, Inc.
>              <kuriyama at FreeBSD.org> // FreeBSD Project
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
> 



More information about the freebsd-current mailing list