Subject: port-shark/36733: ofctl(8) breaks due to an assertion
To: None <port-shark-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <jmmv@NetBSD.org>
List: netbsd-bugs
Date: 08/05/2007 14:05:00
>Number:         36733
>Category:       port-shark
>Synopsis:       ofctl(8) breaks due to an assertion
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-shark-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 05 14:05:00 +0000 2007
>Originator:     Julio M. Merino Vidal
>Release:        NetBSD 4.99.26
>Organization:
	
>Environment:
	
	
System: NetBSD sphinx 4.99.26 NetBSD 4.99.26 (SPHINX) #25: Sun Aug 5 15:14:13 CEST 2007 jmmv@calypso.home.network:/Volumes/NetBSD/obj.shark/Volumes/NetBSD/src/sys/arch/shark/compile/SPHINX shark
Architecture: arm
Machine: shark
>Description:
	When running 'ofctl' without arguments on NetBSD/shark 4.99.26,
	the command aborts quickly due to a failed assertion.  Running the
	utility with the -p flag works correctly though.  This is (I believe)
	because the root node does not have a name (it is empty) but the
	code thinks it should have one.

	Here goes the output:

# ofctl
assertion "len > 0" failed: file "/Volumes/NetBSD/src/usr.sbin/ofctl/ofctl.c", line 562, function "ofname"
[Caching 50 nodes and 306 properties]
#

	The binary is:

/usr/sbin/ofctl:
     $NetBSD: crt0.c,v 1.6 2002/01/01 01:31:06 thorpej Exp $
     $NetBSD: ofctl.c,v 1.7 2007/08/05 13:52:44 jmmv Exp $

	And the gdb session:

# gdb ofctl
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "arm--netbsdelf"...(no debugging symbols found)

(gdb) run
Starting program: /usr/sbin/ofctl 
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
assertion "len > 0" failed: file "/Volumes/NetBSD/src/usr.sbin/ofctl/ofctl.c", line 562, function "ofname"
[Caching 50 nodes and 306 properties]

Program received signal SIGABRT, Aborted.
0x200981f0 in kill () from /usr/lib/libc.so.12
(gdb) bt
#0  0x200981f0 in kill () from /usr/lib/libc.so.12
#1  0x2014a950 in abort () from /usr/lib/libc.so.12
#2  0x20104da8 in __assert13 () from /usr/lib/libc.so.12
#3  0x00009ea8 in ofname ()
#4  0x0000a868 in oflist ()
#5  0x0000ae58 in main ()
(gdb) kill
Kill the program being debugged? (y or n) (gdb) quit
#

>How-To-Repeat:
	Simply run 'ofctl' under NetBSD/shark.  I don't know if this is
	reproducible on other platforms with OpenFirmware, hence why I'm
	filing this in the port-shark category.  If confirmed on other
	platforms, reclassify under 'bin'.

>Fix:
	Properly handle the root node.  Need to understand how it is
	working on other platforms first, assuming it not fails there too.

>Unformatted: