Wed 23 Dec 2009 07:05:03 PM UTC, original submission:
Hi,
On my NetBSD 5.0 box, grub-probe systematically segfaults when given a device map.
$ ./grub-mkdevicemap -m /tmp/device.map
$ cat /tmp/device.map
(fd0) /dev/rfd0a
(hd0) /dev/rsd0d
$ ./grub-probe --verbose -m /tmp/device.map --target=device /dev/sd0e
Segmentation fault
Replacing rsd0d by sd0d in the device map does not seem to change anything.
$ gdb ./grub-probe
(gdb) run --verbose -m /tmp/device.map --target=device /dev/sd0e
Starting program: /usr/tmp/GREG/tmp/grub2_2009-12-22/grub-probe --verbose -m /tmp/device.map --target=device /dev/sd0e
Program received signal SIGSEGV, Segmentation fault.
0x08049fd3 in grub_util_biosdisk_iterate (hook=0xbfbfe968) at util/hostdisk.c:157
157 if (map[i].drive && hook (map[i].drive))
(gdb) bt
#0 0x08049fd3 in grub_util_biosdisk_iterate (hook=0xbfbfe968) at util/hostdisk.c:157
#1 0x0804c591 in grub_disk_dev_iterate (hook=0xbfbfe968) at kern/disk.c:212
#2 0x0804c0cf in grub_device_iterate (hook=0x806e1d3 <hook.2683>) at kern/device.c:159
#3 0x0806e2d0 in grub_raid_register (raid=0x8079844) at disk/raid.c:652
#4 0x0806e5d5 in grub_mod_init (mod=0x0) at disk/mdraid_linux.c:227
#5 0x0806e5bd in grub_mdraid_init () at disk/mdraid_linux.c:225
#6 0x0806f842 in grub_init_all () at grub_probe_init.c:52
#7 0x08049ec0 in main (argc=6, argv=0xbfbfea64) at util/grub-probe.c:423
(gdb) quit
This problem is solved if I apply the attached patch, which basically makes sure that all variables accessed by pointers to nested functions are declared static. The patch focuses on a subpart of the sources. I'm no C expert, and I must say I don't really understand what's hapening here.
Sources : bazaar trunk, 22 dec 2009 (rev 1977).
Build command : ./autogen.sh && ./configure CC=/usr/pkg/gcc44/bin/gcc CPPFLAGS=-DHAVE_OPENDISK CFLAGS=-g LDFLAGS="-lintl -lutil" && gmake grub-probe grub-mkdevicemap
|