Linux Backend: SIGSEGV when building without USE_PCI_IDS

Thomas Reitmayr treitmayr at devbase.at
Sat Nov 24 14:49:53 PST 2007


Hi,
I build HAL 0.5.9.1 without USE_PCI_IDS for an ARM target and got a
segmentation fault when starting up hald. The last output and the
backtrace are:


22:58:18.182 [I] device.c:3319: add_dev: subsys=pci sysfs_path=/sys/devices/pci0000:00/0000:00:01.0 dev= parent_dev=0x00000000

Program received signal SIGSEGV, Segmentation fault.
0x4024ca34 in strlen () from /lib/libc.so.6
(gdb) bt
#0  0x4024ca34 in strlen () from /lib/libc.so.6
#1  0x400a4264 in g_strdup () from /usr/lib/libglib-2.0.so.0
#2  0x00011b1c in hal_property_set_string (prop=0x4b3e0, value=0x10 <Address 0x10 out of bounds>) at device.c:214
#3  0x00011c40 in hal_device_property_set_string (device=0x4f2a0, key=0x35398 "pci.vendor", value=0x10 <Address 0x10 out of bounds>)
    at device.c:1070
#4  0x00023fd4 in pci_add (sysfs_path=<value optimized out>, device_file=<value optimized out>, parent_dev=<value optimized out>, 
    parent_path=<value optimized out>) at device.c:1391
#5  0x00028448 in hotplug_event_begin_add_dev (subsystem=0x40364018 "pci", sysfs_path=0x40364118 "/sys/devices/pci0000:00/0000:00:01.0", 
    device_file=0x40364318 "", parent_dev=0x0, parent_path=0x40394 "", end_token=0x4b47c) at device.c:3345
#6  0x0001fda4 in hotplug_event_process_queue () at hotplug.c:160
#7  0x0000f324 in process_reply (m=0x4c230, hb=0x64860) at hald_runner.c:678
#8  0x0000f718 in call_notify (pending=0x64800, user_data=0x64860) at hald_runner.c:689
#9  0x4011c138 in ?? () from /usr/lib/libdbus-1.so.3
Cannot access memory at address 0x1


I think I found the problem, which also seems to be present in the
repository. In hald/linux/device.c the local variables vendor_name,
product_name etc. are declared but not initialized. Then the function
ids_find_pci(..) is called to fill those local variables with strings
from the PCI ids file. Without USE_PCI_IDS being defined however
ids_find_pci(..) is just an inline function which returns immediately
without touching any of the parameters.
Now the next lines compare the local variables with NULL. In my case
this accesses non-initialized variables!

My proposal is to either initialize the variables when declared or set
the respective parameters in the inlined ids_find_pci to NULL.

I did not check whether the same problem exists for USB ids or in any
other place in the code.

Regards,
-Thomas



More information about the hal mailing list