Subject: bin/2482: bad system call in vi
To: None <gnats-bugs@NetBSD.ORG>
From: Taras Ivanenko <ivanenko@ctps01.mit.edu>
List: netbsd-bugs
Date: 05/29/1996 12:19:43
>Number:         2482
>Category:       bin
>Synopsis:       VI closes bad file descriptor.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 29 12:35:04 1996
>Last-Modified:
>Originator:     Taras Ivanenko
>Organization:
MIT
	
>Release:        <NetBSD-current source date> May 24, 1996
>Environment:
	
System: NetBSD ctps01.mit.edu 1.1 NetBSD 1.1 (ctp-sun-slc-disk) #0: Wed Mar 20 22:54:14 EST 1996 ivanenko@ctps03.mit.edu:/usr/src/sys/arch/sparc/compile/ctp-sun-slc-disk sparc

Utilities and libraries are from May 24, 1996, 

>Description:
  I noticed that problem when I got NFS broken while updating the
system. vi was not working at all when NFS file systems on diskless
machine were not fully accessible. Anyway, I run ktrace vi and saw vi die
on system error. When I had the system back on line, the problem
persisted. Now it is not critical but the files should not be closed twice
-- this is definitely a bug. I do not know in what portion of the code the
bug appears: vi code or libc code.

>How-To-Repeat:
  1) chmod 0 /var/tmp/vi.recover to trigger error message.
  2) ktrace vi, ignore error message and exit.
  3) kdump
  4) do not forget to restore permissions! chmod 1777 /var/tmp/vi.recover.

Here is the output: (search for "/C/" and go back a page)
  3384 vi       NAMI  "/etc/vi.exrc"
  3384 vi       RET   stat -1 errno 2 No such file or directory
  3384 vi       CALL  stat(0xf7fff0c8,0xf7fff528)
  3384 vi       NAMI  "/usr/users/ivanenko/.nexrc"
  3384 vi       RET   stat -1 errno 2 No such file or directory
  3384 vi       CALL  stat(0xf7fff0c8,0xf7fff528)
  3384 vi       NAMI  "/usr/users/ivanenko/.exrc"
  3384 vi       RET   stat -1 errno 2 No such file or directory
  3384 vi       CALL  break(0x68ffc)
  3384 vi       RET   break 0
  3384 vi       CALL  getpid
  3384 vi       RET   getpid 3384/0xd38
  3384 vi       CALL  stat(0xf7fff108,0xf7ffefd0)
  3384 vi       NAMI  "/tmp"
  3384 vi       RET   stat 0
  3384 vi       CALL  open(0xf7fff108,0xa02,0x180)
  3384 vi       NAMI  "/tmp/vi.003384"
  3384 vi       RET   open 3
  3384 vi       CALL  close(0x3)
  3384 vi       RET   close 0
  3384 vi       CALL  stat(0x67040,0xf7fff040)
  3384 vi       NAMI  "/var/tmp/vi.recover"
  3384 vi       RET   stat 0
  3384 vi       CALL  getpid
  3384 vi       RET   getpid 3384/0xd38
  3384 vi       CALL  stat(0xf7ffec40,0xf7ffeaa0)
  3384 vi       NAMI  "/var/tmp/vi.recover"
  3384 vi       RET   stat 0
  3384 vi       CALL  open(0xf7ffec40,0xa02,0x180)
  3384 vi       NAMI  "/var/tmp/vi.recover/vi.003384"
  3384 vi       RET   open -1 errno 13 Permission denied
  3384 vi       CALL  stat(0xf7ffe560,0xf7ffe960)
  3384 vi       NAMI  "/usr/share/nls/C/libc.cat"
  3384 vi       RET   stat 0
  3384 vi       CALL  open(0xf7ffe560,0,0)
  3384 vi       NAMI  "/usr/share/nls/C/libc.cat"
  3384 vi       RET   open 3
  3384 vi       CALL  fstat(0x3,0xf7ffe960)
  3384 vi       RET   fstat 0
  3384 vi       CALL  mmap(0,0x13d6,0x1,0x1,0x3,0,0,0)
  3384 vi       RET   mmap 67526656/0x4066000
  3384 vi       CALL  close(0x3)
  3384 vi       RET   close 0
  3384 vi       CALL  close(0x3)
  3384 vi       RET   close -1 errno 9 Bad file descriptor
  3384 vi       CALL  open(0x67140,0x4,0x1b6)
  3384 vi       NAMI  "/tmp/vi.003384"
  3384 vi       RET   open 3
  3384 vi       CALL  sigprocmask(0x1,0xffffffff)
  3384 vi       RET   sigprocmask 0

Notice that FD 0x3 was closed twice above.

>Fix:
	
  Sorry, I do not have time to look into the problem now, maybe sometimes
in July if if will not be fixed already.
>Audit-Trail:
>Unformatted: