Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Apr 2013 18:54:11 +0300
From:      Kimmo Paasiala <kpaasial@gmail.com>
To:        freebsd-hackers@freebsd.org, freebsd-stable@freebsd.org,  FreeBSD current <freebsd-current@freebsd.org>
Subject:   config(8) -x headscratcher
Message-ID:  <CA%2B7WWSeZ=Mg=-duGY-RHZ=n8vrJtDRM28jwCr1Szv4t_4Cdh%2Bw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I'm getting a core dump on 'config -x /boot/kernel/kernel' on 9.1-RELEASE i386.

Assertion failed: (r != '\0' && ("Char present in the configuration "
"string mustn't be equal to 0")), function kernconfdump, file
/usr/src/usr.sbin/config/main.c, line 710.

I have double checked that my config file is sane and does not have
any funny characters anywhere.

The system is i386 9.1-RELEASE r249856. The world and kernel are built
with clang and I'm suspecting that the use of clang has something to
do with this segfault.

Looking at the kernel files I can see one very obvious difference.
This is the 'elfdump -c kernel | grep -A 8 kern_conf' output (what
config -x seems to use for finding out the config file from the kernel
image) for the GENERIC kernel from the stock installation:

	sh_name: kern_conf
	sh_type: SHT_PROGBITS
	sh_flags: SHF_ALLOC
	sh_addr: 0xc1039f80
	sh_offset: 12820352
	sh_size: 3771
	sh_link: 0
	sh_info: 0
	sh_addralign: 32

And this is from the kernel I have built myself using clang and a
custom config file:

	sh_name: kern_conf
	sh_type: SHT_PROGBITS
	sh_flags: SHF_ALLOC
	sh_addr: 0xc09aee9c
	sh_offset: 5959324
	sh_size: 1994
	sh_link: 0
	sh_info: 0
	sh_addralign: 1

The align field looks suspicious, config -x seems to use it to check
for padding but to me it looks like the logic may not work if the
alignment is 1.

This the relevant bit from main.c of config(8)

if (r == '\0' && (size - i) < align)
    break;
assert(r != '\0' && ("Char present in the configuration "
    "string mustn't be equal to 0"));
fputc(r, stdout);


-Kimmo



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B7WWSeZ=Mg=-duGY-RHZ=n8vrJtDRM28jwCr1Szv4t_4Cdh%2Bw>