Subject: port-alpha/15156: gcc 2.95.3 with -O2 generates bad newfs(8) binary
To: None <gnats-bugs@gnats.netbsd.org>
From: None <lukem@netbsd.org>
List: netbsd-bugs
Date: 01/07/2002 10:07:53
>Number:         15156
>Category:       port-alpha
>Synopsis:       gcc 2.95.3 with -O2 generates bad newfs(8) binary
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-alpha-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 06 15:08:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Luke Mewburn
>Release:        NetBSD 1.5ZA
>Organization:
Luke Mewburn  <lukem@wasabisystems.com>  http://www.wasabisystems.com
Luke Mewburn     <lukem@netbsd.org>      http://www.netbsd.org
Wasabi Systems - NetBSD hackers for hire
NetBSD - the world's most portable UNIX-like operating system
>Environment:
	
	
System: NetBSD karybdis 1.5ZA NetBSD 1.5ZA (KARYBDIS) #47: Sun Dec 30 18:17:38 EST 2001 lukem@karybdis:/var/scratch/obj.alpha/sys/KARYBDIS alpha
Architecture: alpha
Machine: alpha
>Description:
	If sbin/newfs is compiled with gcc -O2 (which is the default
	from <sys.mk>), using the new toolchain gcc 2.95.3, the
	resultant newfs binary SEGVs in certain circumstances.

	The SEGV problem was reported on port-alpha by Christopher SEKIYA
	and I tracked it down to the optimisation level.

	Interestingly, mount_mfs (which is a link to newfs) seems to
	work ok (for 96MB and 128MB mounts)

>How-To-Repeat:

	% ./newfs -N -F -s 500m /var/tmp/fs
	/var/tmp/fs:    1024000 sectors in 1000 cylinders of 16 tracks, 64 sectors
		500.0MB in 12 cyl groups (85 c/g, 42.50MB/g, 10368 i/g)
	super-block backups (for fsck -b #) at:
	     32,  87136,Segmentation fault(core dumped)

	% gdb ./newfs newfs.core
	GNU gdb 5.0-nb1
	This GDB was configured as "alpha-unknown-netbsd"...
	Core was generated by `newfs'.
	Program terminated with signal 11, Segmentation fault.
	#0  initcg (cylno=2, utime=597) at
	/usr/src/sbin/newfs/mkfs.c:780
	780                                     sump[run]++;
	(gdb) list
	775                             if ((map & bit) != 0) {
	776                                     run++;
	777                             } else if (run != 0) {
	778                                     if (run > sblock.fs_contigsumsize)
	779                                             run = sblock.fs_contigsumsize;
	780                                     sump[run]++;
	781                                     run = 0;
	782                             }
	783                             if ((i & (NBBY - 1)) != (NBBY - 1)) {
	784                                     bit <<= 1;
	(gdb)

>Fix:
	I've temporarily worked around this in newfs' Makefile by
	cranking down the optimisation level on the Alpha port.
	Obviously this is not a long term solution.
>Release-Note:
>Audit-Trail:
>Unformatted: