Subject: bin/34111: config(8) crashes if disabling a pseudo-device as a device (e.g. 'no ccd')
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <jmmv@netbsd.org>
List: netbsd-bugs
Date: 07/29/2006 10:40:00
>Number:         34111
>Category:       bin
>Synopsis:       config(8) crashes if disabling a pseudo-device as a device (e.g. 'no ccd')
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 29 10:40:00 +0000 2006
>Originator:     Julio M. Merino Vidal
>Release:        NetBSD 3.99.23
>Organization:
	
>Environment:
	
	
System: NetBSD dawn.home.network 3.99.23 NetBSD 3.99.23 (GENERIC) #22: Fri Jul 28 14:56:33 CEST 2006 root@max.home.network:/var/obj/usr/src-current/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	Consider the following configuration test-case kernel config (TEST):

	include "arch/i386/conf/GENERIC"
	no ccd

	As you can see, this tries to disable the 'ccd' pseudo-device using
	the syntax to disable regular devices.  I.e., it should really read
	'no pseudo-device ccd', but people can easily make that mistake.

	However, config(8) does not detect this syntax error condition and
	later causes a crash with no information on what happened.
	Fortunately gdb shed some light to find the problem (the keyword
	I missed) so I could fix my kernel config.

	The command I used was this:

	dawn:/tmp> ./config -s ~/NetBSD/src/sys -b test TEST

	And it resulted in a core dump.  The same happened while using
	build.sh.  (I'm using './config' because it is a binary I built by
	hand with debugging information.)

	gdb provides the following information about the crash:

	dawn:/tmp> gdb ./config test/config.core
	GNU gdb 5.3nb1
	Copyright 2002 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 "i386--netbsdelf"...
	Core was generated by `config'.
	Program terminated with signal 11, Segmentation fault.
	Reading symbols from /usr/lib/libc.so.12...done.
	Loaded symbols for /usr/lib/libc.so.12
	Reading symbols from /usr/libexec/ld.elf_so...done.
	Loaded symbols for /usr/libexec/ld.elf_so
	#0  0x08057a06 in remove_devi (i=0x8172c80) at sem.c:1177
	1177                *ppi != NULL && *ppi != i && (*ppi)->i_asame != i;
	(gdb) bt
	#0  0x08057a06 in remove_devi (i=0x8172c80) at sem.c:1177
	#1  0x0805808a in deldev (name=0x80e0120 "ccd") at sem.c:1380
	#2  0x0804bcbd in yyparse () at gram.y:459
	#3  0x0804d032 in main (argc=-1077941828, argv=0x80492d0) at main.c:342
	#4  0x080492d0 in ___start ()
	(gdb)

>How-To-Repeat:
	See above.  Procedure mixed with description.

>Fix:
	Catch that foo in 'no foo' might be a pseudo device and note the user
	where the problem is.

>Unformatted: