Subject: Re: tailing of /kern/msgbuf
To: None <netbsd-users@NetBSD.org,>
From: Hubert Feyrer <hubertf@gmx.de>
List: netbsd-users
Date: 08/22/2005 04:37:41
In article <FFENIJPEMNGOKCCHNAKLOEBPIIAA.Scott.Burns@Netcontech.Com> you wrote:
> I am using NetBSD/i386 V2.0.2 and frequently on my servers if I try:
> 
> cd /kern
> tail msgbuf
> 
> I receive a: "Segmentation fault"
> 
> Not 100% of the time, but more than not.
> 
> Has this been observed before ? I can't find mention of it.

Poking it seems that the mmap() in forward.c:305 returns a 0 pointer (see 
below0, which seems pretty strange to me. I can understand why mmap() 
would not work on this kind of file, but I'd argue that tail(1) should 
fall back to just open(2) and maybe lseek(2) and read(2) then.

Looking at other implementations (source) may be interesting...


 - Hubert



(gdb) run /kern/msgbuf
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /usr/cvs/src-current/usr.bin/tail/obj/tail /kern/msgbuf

Breakpoint 1, rlines (fp=0x4810a340, off=10, sbp=0xbfbff3a0)
    at /usr/src/usr.bin/tail/forward.c:304
304             while (off) {
(gdb) p off
$9 = 10
(gdb) p mmap_size
$10 = 16368
(gdb) p mmap_offset
$11 = 0
(gdb) step
305                     start = mmap(NULL, (size_t)mmap_size, PROT_READ,
(gdb) 
307                     if (start == MAP_FAILED) {
(gdb) p start
$12 = 0x0
(gdb) print *start
Error accessing memory address 0x0: Invalid argument.
(gdb)