Subject: Re: port-i386/37155: mount: /tmp: Segmentation fault error at boot in netbsd-4-rc-3
To: None <port-i386-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
List: netbsd-bugs
Date: 10/20/2007 16:55:08
The following reply was made to PR port-i386/37155; it has been noted by GNATS.

From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-i386/37155: mount: /tmp: Segmentation fault error at boot in netbsd-4-rc-3
Date: Sat, 20 Oct 2007 18:53:19 +0200

 On Sat, Oct 20, 2007 at 04:25:02PM +0000, Marcelo Schmidt wrote:
 <snip>
 >  # NetBSD /etc/fstab
 >  # See /usr/share/examples/fstab/ for more examples.
 >  /dev/ld0a               /       ffs     rw               1 1
 >  /dev/ld0b               none    swap    sw               0 0
 >  /dev/ld0e               /usr    ffs     rw               1 2
 >  /dev/ld0f               /var    ffs     rw               1 2
 >  /dev/ld0g               /home   ffs     rw               1 2
 >  /dev/ld0b               /tmp    mfs	rw,-s=3D8193150
 
 8193150 * 512 = 4194892800 = 0xfa08fc00 is a rather large mfs
 
 <snip>
 >     913      1 mount_mfs CALL  mmap(0,0xbbc58000,3,0x1002,0xffffffff,0,0,0)
 >     913      1 mount_mfs RET   mmap -1 errno 22 Invalid argument
 
 Here mmap() fails.  Now look at src/sbin/newfs/mkfs.c and see code like this:
 
 	calc_memfree();
 	if (fssize * sectorsize > memleft)
 		fssize = memleft / sectorsize;
 	if ((membase = mkfs_malloc(fssize * sectorsize)) == 0)
 		exit(12);
 
 
 where
 
 	static void *
 	mkfs_malloc(size_t size)
 		...
 		return (mmap(0, size, ...
 
 Looks like all tests of mmap() against NULL need conversion to MAP_FAILED.
 
 -- 
 Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)