amd64/123456: /usr/bin/fstat shows error messages and hang.

KOIE Hidetaka hide at koie.org
Tue May 6 11:00:05 UTC 2008


>Number:         123456
>Category:       amd64
>Synopsis:       /usr/bin/fstat shows error messages and hang.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-amd64
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 06 11:00:04 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     KOIE Hidetaka
>Release:        FreeBSD 8.0-CURRENT amd64
>Organization:
surigiken
>Environment:
System: FreeBSD guriandgura 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Mon May 5 13:17:50 JST 2008 koie at guriandgura:/usr/obj/usr/src\
/sys/GURIANDGURA amd64

>Description:
        fstat -v shows error message like this:
                can't read vnode at 0x0 for pid ***
                can't read znode_phys at 0x**** for pid ***
                unknown file type 5 for file 5 of pid ***

        fstat / hangs.

>How-To-Repeat:

>Fix:
        Patch for "can't read vnode at 0x0 for pid ***":
        vtrans() is invoked iff vp is not null.

        Patch for "can't read znode_phys at 0x**** for pid ***":
        znode_phys is void *, not int.

        Patch for "unknown file type 5 for file 5 of pid ***":
        consider other DTYPEs.

        Patch for hanging:
        sysctl "debug.sizeof.znode" returns int, not size_t.


Patch attached with submission follows:

diff -c -r1.65 fstat.c
*** fstat.c	5 Nov 2007 23:15:02 -0000	1.65
--- fstat.c	6 May 2008 10:11:33 -0000
***************
*** 348,354 ****
  	/*
  	 * current working directory vnode
  	 */
! 	vtrans(filed.fd_cdir, CDIR, FREAD);
  	/*
  	 * jail root, if any.
  	 */
--- 348,355 ----
  	/*
  	 * current working directory vnode
  	 */
! 	if (filed.fd_cdir)
! 		vtrans(filed.fd_cdir, CDIR, FREAD);
  	/*
  	 * jail root, if any.
  	 */
***************
*** 390,417 ****
  			    i, (void *)ofiles[i], Pid);
  			continue;
  		}
! 		if (file.f_type == DTYPE_VNODE)
  			vtrans(file.f_vnode, i, file.f_flag);
! 		else if (file.f_type == DTYPE_SOCKET) {
  			if (checkfile == 0)
  				socktrans(file.f_data, i);
! 		}
  #ifdef DTYPE_PIPE
! 		else if (file.f_type == DTYPE_PIPE) {
  			if (checkfile == 0)
  				pipetrans(file.f_data, i, file.f_flag);
! 		}
  #endif
  #ifdef DTYPE_FIFO
! 		else if (file.f_type == DTYPE_FIFO) {
  			if (checkfile == 0)
  				vtrans(file.f_vnode, i, file.f_flag);
! 		}
  #endif
! 		else {
  			dprintf(stderr,
  			    "unknown file type %d for file %d of pid %d\n",
  			    file.f_type, i, Pid);
  		}
  	}
  }
--- 391,435 ----
  			    i, (void *)ofiles[i], Pid);
  			continue;
  		}
! 		switch (file.f_type) {
! 		case DTYPE_VNODE:
  			vtrans(file.f_vnode, i, file.f_flag);
! 			break;
! 		case DTYPE_SOCKET:
  			if (checkfile == 0)
  				socktrans(file.f_data, i);
! 			break;
  #ifdef DTYPE_PIPE
! 		case DTYPE_PIPE:
  			if (checkfile == 0)
  				pipetrans(file.f_data, i, file.f_flag);
! 			break;
  #endif
  #ifdef DTYPE_FIFO
! 		case DTYPE_FIFO:
  			if (checkfile == 0)
  				vtrans(file.f_vnode, i, file.f_flag);
! 			break;
  #endif
! #ifdef DTYPE_KQUEUE
! 		case DTYPE_KQUEUE:
! #endif
! #ifdef DTYPE_CRYPTO
! 		case DTYPE_CRYPTO:
! #endif
! #ifdef DTYPE_MQUEUE
! 		case DTYPE_MQUEUE:
! #endif
! #ifdef DTYPE_SHM
! 		case DTYPE_SHM:
! #endif
! 			/* not supported */
! 			break;
! 		default:
  			dprintf(stderr,
  			    "unknown file type %d for file %d of pid %d\n",
  			    file.f_type, i, Pid);
+ 			break;
  		}
  	}
  }
diff -c -r1.2 zfs.c
*** zfs.c	17 Nov 2007 23:21:38 -0000	1.2
--- zfs.c	6 May 2008 10:02:48 -0000
***************
*** 68,75 ****
  	uint64_t *zid;
  	void *znodeptr, *vnodeptr;
  	char *dataptr;
! 	int *zphys_addr;
! 	size_t len, size;
  
  	len = sizeof(size);
  	if (sysctlbyname("debug.sizeof.znode", &size, &len, NULL, 0) == -1) {
--- 68,76 ----
  	uint64_t *zid;
  	void *znodeptr, *vnodeptr;
  	char *dataptr;
! 	void *zphys_addr;
! 	size_t len;
! 	int size;
  
  	len = sizeof(size);
  	if (sysctlbyname("debug.sizeof.znode", &size, &len, NULL, 0) == -1) {
***************
*** 84,90 ****
  
  	/* Since we have problems including vnode.h, we'll use the wrappers. */
  	vnodeptr = getvnodedata(vp);
! 	if (!KVM_READ(vnodeptr, znodeptr, size)) {
  		dprintf(stderr, "can't read znode at %p for pid %d\n",
  		    (void *)vnodeptr, Pid);
  		goto bad;
--- 85,91 ----
  
  	/* Since we have problems including vnode.h, we'll use the wrappers. */
  	vnodeptr = getvnodedata(vp);
! 	if (!KVM_READ(vnodeptr, znodeptr, (size_t)size)) {
  		dprintf(stderr, "can't read znode at %p for pid %d\n",
  		    (void *)vnodeptr, Pid);
  		goto bad;
***************
*** 99,107 ****
  	 */
  	dataptr = znodeptr;
  	zid = (uint64_t *)(dataptr + LOCATION_ZID);
! 	zphys_addr = (int *)(dataptr + LOCATION_ZPHYS(size));
  
! 	if (!KVM_READ(*zphys_addr, &zphys, sizeof(zphys))) {
  		dprintf(stderr, "can't read znode_phys at %p for pid %d\n",
  		    zphys_addr, Pid);
  		goto bad;
--- 100,108 ----
  	 */
  	dataptr = znodeptr;
  	zid = (uint64_t *)(dataptr + LOCATION_ZID);
! 	zphys_addr = *(void **)(dataptr + LOCATION_ZPHYS(size));
  
! 	if (!KVM_READ(zphys_addr, &zphys, sizeof(zphys))) {
  		dprintf(stderr, "can't read znode_phys at %p for pid %d\n",
  		    zphys_addr, Pid);
  		goto bad;



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-amd64 mailing list