Subject: latest fsck dumped core
To: None <netbsd-bugs@sun-lamp.cs.berkeley.edu>
From: Frank van der Linden <vdlinden@fwi.uva.nl>
List: netbsd-bugs
Date: 06/12/1994 17:59:45
 In my latest NetBSD-current (June 12) the automatic fsck told
me to run fsck manually. When I did it: segmentation violation,
core dumped. The old (pre June 9) fsck did fix the problem.

Below is a two part script(1) output which demonstrates
what was going on before I ran the 'old' fsck. I hope someone
can derive something useful from it.

Onno van der Linden     c/o      vdlinden@fwi.uva.nl (Frank van der Linden)

------------------PART 1------------------
Script started on Sun Jun 12 17:11:01 1994
# fsck
** /dev/rwd0a
** Last Mounted on /
** Root file system
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
DIRECTORY CORRUPTED  I=5  OWNER=root MODE=41777
SIZE=1024 MTIME=May 22 12:20 1993 
DIR=/lost+found

SALVAGE? [yn] y

Segmentation fault - core dumped
# gdb /sbin/fsck fsck.core
Core was generated by `fsck'.
Program terminated with signal 11, Segmentation fault.
#0  0x0 in _DYNAMIC ()
(gdb) where
#0  0x0 in _DYNAMIC ()
(gdb) quit
# ls -al /sbin/fsck
-rwxr-xr-x  1 root  wheel  353557 Jun 12 17:08 /sbin/fsck
# echo /lost+found/*
/lost+found/#1751
ls: #: No such file or directory
total 4
drwxrwxrwt   2 root  wheel  1024 May 22  1993 .
drwxr-xr-x  13 root  wheel   512 Jun 12 17:11 ..


--------------------- PART 2 -------------------

Script started on Sun Jun 12 17:20:47 1994
# gdb /sbin/fsck
(gdb) break reply
Breakpoint 1 at 0xa8c6: file /usr/src/sbin/fsck/utilities.c, line 79.
(gdb) run
Starting program: /sbin/fsck 
** /dev/rwd0a
** Last Mounted on /
** Root file system
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
DIRECTORY CORRUPTED  I=5  OWNER=root MODE=41777
SIZE=1024 MTIME=May 22 12:20 1993 
DIR=/lost+found

Breakpoint 1, reply (question=0xb80d "SALVAGE")
    at /usr/src/sbin/fsck/utilities.c:79
79              if (preen)
(gdb) 
(gdb) step
81              persevere = !strcmp(question, "CONTINUE");
(gdb) 
82              printf("\n");
(gdb) 

83              if (!persevere && (nflag || fswritefd < 0)) {
(gdb) 
87              if (yflag || (persevere && nflag)) {
(gdb) 
92                      printf("%s? [yn] ", question);
(gdb) 
93                      (void) fflush(stdout);
(gdb) 
SALVAGE? [yn] 94                        c = getc(stdin);
(gdb) 
y
95                      while (c != '\n' && getc(stdin) != '\n')
(gdb) 
98              } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
(gdb) 
99              printf("\n");
(gdb) 

100             if (c == 'y' || c == 'Y')
(gdb) 
89                      return (1);
(gdb) 
103     }
(gdb) 
dofix (idesc=0xf7bfdd3c, msg=0x28898 "") at /usr/src/sbin/fsck/utilities.c:498
498                     idesc->id_fix = FIX;
(gdb) 
499                     return (ALTERED);
(gdb) 
512     }
(gdb) 
fsck_readdir (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:197
197                     bp = getdirblk(idesc->id_blkno, blksiz);
(gdb) 
getdirblk (blkno=356, size=1024) at /usr/src/sbin/fsck/dir.c:678
678             if (pdirbp != 0)
(gdb) 
679                     pdirbp->b_flags &= ~B_INUSE;
(gdb) 
680             pdirbp = getdatablk(blkno, size);
(gdb) 
getdatablk (blkno=356, size=1024) at /usr/src/sbin/fsck/utilities.c:152
152             for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
(gdb) 
153                     if (bp->b_bno == fsbtodb(&sblock, blkno))
(gdb) 
152             for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
(gdb) 
153                     if (bp->b_bno == fsbtodb(&sblock, blkno))
(gdb) 
152             for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
(gdb) 
153                     if (bp->b_bno == fsbtodb(&sblock, blkno))
(gdb) 
163             totalreads++;
(gdb) 
164             bp->b_prev->b_next = bp->b_next;
(gdb) 
165             bp->b_next->b_prev = bp->b_prev;
(gdb) 
166             bp->b_prev = &bufhead;
(gdb) 
167             bp->b_next = bufhead.b_next;
(gdb) 
168             bufhead.b_next->b_prev = bp;
(gdb) 
169             bufhead.b_next = bp;
(gdb) 
170             bp->b_flags |= B_INUSE;
(gdb) 
171             return (bp);
(gdb) 
172     }
(gdb) 
getdirblk (blkno=356, size=1024) at /usr/src/sbin/fsck/dir.c:682
682     }
(gdb) 
fsck_readdir (idesc=0x164) at /usr/src/sbin/fsck/dir.c:198
198                     dp = (struct direct *)(bp->b_un.b_buf + dploc);
(gdb) 
199                     dp->d_reclen += size;
(gdb) 
200                     if (fix)
(gdb) 
201                             dirty(bp);
(gdb) 
203             return (dp);
(gdb) 
204     }
(gdb) 
dirscan (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:112
112                     dsize = dp->d_reclen;
(gdb) 
113                     bcopy((char *)dp, dbuf, (size_t)dsize);
(gdb) 
115                             if (!newinofmt) {
(gdb) 
119                                     tmp = tdp->d_namlen;
(gdb) 
120                                     tdp->d_namlen = tdp->d_type;
(gdb) 
121                                     tdp->d_type = tmp;
(gdb) 
124                     idesc->id_dirp = (struct direct *)dbuf;
(gdb) 
125                     if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
(gdb) 

pass2check (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/pass2.c:196
196             register struct direct *dirp = idesc->id_dirp;
(gdb) 
198             int n, entrysize, ret = 0;
(gdb) 
208             if (doinglevel2 && dirp->d_ino > 0 && dirp->d_ino < maxino) {
(gdb) 
215             if (idesc->id_entryno != 0)
(gdb) 
264             if (idesc->id_entryno > 1)
(gdb) 
266             inp = getinoinfo(idesc->id_number);
(gdb) 
getinoinfo (inumber=5) at /usr/src/sbin/fsck/inode.c:344
344             for (inp = inphead[inumber % numdirs]; inp; inp = inp->i_nexthash) {
(gdb) 
345                     if (inp->i_number != inumber)
(gdb) 
351     }
(gdb) 
pass2check (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/pass2.c:267
267             proto.d_ino = inp->i_parent;
(gdb) 
268             if (newinofmt)
(gdb) 
271                     proto.d_type = 0;
(gdb) 
272             proto.d_namlen = 2;
(gdb) 
273             (void)strcpy(proto.d_name, "..");
(gdb) 
274             entrysize = DIRSIZ(0, &proto);
(gdb) 
275             if (idesc->id_entryno == 0) {
(gdb) 
287             if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) {
(gdb) 
288                     inp->i_dotdot = dirp->d_ino;
(gdb) 
289                     if (newinofmt && dirp->d_type != DT_DIR) {
(gdb) 
322             if (dirp->d_ino == 0)
(gdb) 
324             if (dirp->d_namlen <= 2 &&
(gdb) 
342             idesc->id_entryno++;
(gdb) 
343             n = 0;
(gdb) 
344             if (dirp->d_ino > maxino) {
(gdb) 
349                     switch (statemap[dirp->d_ino]) {
(gdb) 
384                             inp = getinoinfo(dirp->d_ino);
(gdb) 
getinoinfo (inumber=2) at /usr/src/sbin/fsck/inode.c:344
344             for (inp = inphead[inumber % numdirs]; inp; inp = inp->i_nexthash) {
(gdb) 
345                     if (inp->i_number != inumber)
(gdb) 
344             for (inp = inphead[inumber % numdirs]; inp; inp = inp->i_nexthash) {
(gdb) 
345                     if (inp->i_number != inumber)
(gdb) 
351     }
(gdb) 
pass2check (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/pass2.c:385
385                             if (inp->i_parent != 0 && idesc->id_entryno > 2) {
(gdb) 
397                             if (idesc->id_entryno > 2)
(gdb) 
402                             if (newinofmt && dirp->d_type != typemap[dirp->d_ino]) {
(gdb) 
409                             lncntp[dirp->d_ino]--;
(gdb) 
410                             break;
(gdb) 
417             if (n == 0)
(gdb) 
418                     return (ret|KEEPON);
(gdb) 
421     }
(gdb) 
dirscan (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:143
143                     if (n & STOP) 
(gdb) 
111             for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
(gdb) 
fsck_readdir (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:160
160             blksiz = idesc->id_numfrags * sblock.fs_fsize;
(gdb) 
161             bp = getdirblk(idesc->id_blkno, blksiz);
(gdb) 
getdirblk (blkno=356, size=1024) at /usr/src/sbin/fsck/dir.c:678
678             if (pdirbp != 0)
(gdb) 
679                     pdirbp->b_flags &= ~B_INUSE;
(gdb) 
680             pdirbp = getdatablk(blkno, size);
(gdb) 
getdatablk (blkno=356, size=1024) at /usr/src/sbin/fsck/utilities.c:152
152             for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
(gdb) 
153                     if (bp->b_bno == fsbtodb(&sblock, blkno))
(gdb) 
163             totalreads++;
(gdb) 
164             bp->b_prev->b_next = bp->b_next;
(gdb) 
165             bp->b_next->b_prev = bp->b_prev;
(gdb) 
166             bp->b_prev = &bufhead;
(gdb) 
167             bp->b_next = bufhead.b_next;
(gdb) 
168             bufhead.b_next->b_prev = bp;
(gdb) 
169             bufhead.b_next = bp;
(gdb) 
170             bp->b_flags |= B_INUSE;
(gdb) 
171             return (bp);
(gdb) 
172     }
(gdb) 
getdirblk (blkno=356, size=1024) at /usr/src/sbin/fsck/dir.c:682
682     }
(gdb) 
fsck_readdir (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:162
162             if (idesc->id_loc % DIRBLKSIZ == 0 && idesc->id_filesize > 0 &&
(gdb) 
164                     dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
(gdb) 
165                     if (dircheck(idesc, dp))
(gdb) 
dircheck (idesc=0xf7bfdd3c, dp=0x55200) at /usr/src/sbin/fsck/dir.c:219
219             size = DIRSIZ(!newinofmt, dp);
(gdb) 
220             spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ);
(gdb) 
222                     if (!newinofmt) {
(gdb) 
223                             type = dp->d_namlen;
(gdb) 
224                             namlen = dp->d_type;
(gdb) 
225                     } else {
(gdb) 
233             if (dp->d_ino < maxino &&
(gdb) 
241                     if (dp->d_ino == 0)
(gdb) 
247                             return (1);
(gdb) 
250     }
(gdb) 
fsck_readdir (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:182
182             if (idesc->id_filesize <= 0 || idesc->id_loc >= blksiz)
(gdb) 
184             dploc = idesc->id_loc;
(gdb) 
185             dp = (struct direct *)(bp->b_un.b_buf + dploc);
(gdb) 
186             idesc->id_loc += dp->d_reclen;
(gdb) 
187             idesc->id_filesize -= dp->d_reclen;
(gdb) 
188             if ((idesc->id_loc % DIRBLKSIZ) == 0)
(gdb) 
203             return (dp);
(gdb) 
204     }
(gdb) 
dirscan (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:112
112                     dsize = dp->d_reclen;
(gdb) 
113                     bcopy((char *)dp, dbuf, (size_t)dsize);
(gdb) 
115                             if (!newinofmt) {
(gdb) 
119                                     tmp = tdp->d_namlen;
(gdb) 
120                                     tdp->d_namlen = tdp->d_type;
(gdb) 
121                                     tdp->d_type = tmp;
(gdb) 
124                     idesc->id_dirp = (struct direct *)dbuf;
(gdb) 
125                     if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
(gdb) 
pass2check (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/pass2.c:196

196             register struct direct *dirp = idesc->id_dirp;

(gdb) 
198             int n, entrysize, ret = 0;
(gdb) 
208             if (doinglevel2 && dirp->d_ino > 0 && dirp->d_ino < maxino) {
(gdb) 
215             if (idesc->id_entryno != 0)
(gdb) 
264             if (idesc->id_entryno > 1)
(gdb) 
322             if (dirp->d_ino == 0)
(gdb) 
418                     return (ret|KEEPON);
(gdb) 
421     }
(gdb) 
dirscan (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:143
143                     if (n & STOP) 
(gdb) 
111             for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
(gdb) 
fsck_readdir (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:160
160             blksiz = idesc->id_numfrags * sblock.fs_fsize;
(gdb) 
161             bp = getdirblk(idesc->id_blkno, blksiz);
(gdb) 
getdirblk (blkno=356, size=1024) at /usr/src/sbin/fsck/dir.c:678
678             if (pdirbp != 0)
(gdb) 
679                     pdirbp->b_flags &= ~B_INUSE;
(gdb) 
680             pdirbp = getdatablk(blkno, size);
(gdb) 
getdatablk (blkno=356, size=1024) at /usr/src/sbin/fsck/utilities.c:152
152             for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
(gdb) 
153                     if (bp->b_bno == fsbtodb(&sblock, blkno))
(gdb) 
163             totalreads++;
(gdb) 
164             bp->b_prev->b_next = bp->b_next;
(gdb) 
165             bp->b_next->b_prev = bp->b_prev;
(gdb) 
166             bp->b_prev = &bufhead;
(gdb) 
167             bp->b_next = bufhead.b_next;
(gdb) 
168             bufhead.b_next->b_prev = bp;
(gdb) 
169             bufhead.b_next = bp;
(gdb) 
170             bp->b_flags |= B_INUSE;
(gdb) 
171             return (bp);
(gdb) 
172     }
(gdb) 
getdirblk (blkno=356, size=1024) at /usr/src/sbin/fsck/dir.c:682
682     }
(gdb) 
fsck_readdir (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:162
162             if (idesc->id_loc % DIRBLKSIZ == 0 && idesc->id_filesize > 0 &&
(gdb) 
182             if (idesc->id_filesize <= 0 || idesc->id_loc >= blksiz)
(gdb) 
183                     return NULL;
(gdb) 
204     }
(gdb) 
dirscan (idesc=0xf7bfdd3c) at /usr/src/sbin/fsck/dir.c:146
146             return (idesc->id_filesize > 0 ? KEEPON : STOP);
(gdb) 
147     }
(gdb) 
Cannot insert breakpoint 0:
Error accessing memory address 0x0: Invalid argument.
(gdb) 
Cannot find bounds of current function
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y

------------------------------------------------------------------------------