Hello,
I experienced a segfault in my program when I ported it to Mac OS X and
hunted it down to the "libusb_get_active_config_descriptor" function in
libusbx. I used version 1.0.14 but also tried 1.0.15rc3 and latest git
HEAD with the same result.
This is my test program (Which displays the active config for all devices):
#include <libusb.h>
#include <stdio.h>
int main(int argc, char **argv)
{
libusb_context *ctx;
libusb_device **list;
libusb_device *device;
ssize_t numDevices, i;
uint8_t bus, address;
printf("libusb_init: %i\n", libusb_init(&ctx));
numDevices = libusb_get_device_list(ctx, &list);
printf("libusb_get_device_list: %i\n", (int) numDevices);
for (i = 0; i < numDevices; i += 1)
{
device = list[i];
bus = libusb_get_bus_number(device);
address = libusb_get_device_address(device);
struct libusb_config_descriptor *config;
printf("libusb_get_active_config_descriptor: %i\n",
libusb_get_active_config_descriptor(device, &config));
printf("%03i/%03i: %i\n", bus, address,
config->bConfigurationValue);
libusb_free_config_descriptor(config);
}
libusb_free_device_list(list, 1);
libusb_exit(ctx);
}
On Linux this program works and gives me an output like this:
libusb_init: 0
libusb_get_device_list: 9
libusb_get_active_config_descriptor: 0
001/001: 1
libusb_get_active_config_descriptor: 0
002/001: 1
libusb_get_active_config_descriptor: 0
001/002: 1
libusb_get_active_config_descriptor: 0
002/002: 1
libusb_get_active_config_descriptor: 0
001/003: 1
libusb_get_active_config_descriptor: 0
002/003: 1
libusb_get_active_config_descriptor: 0
002/004: 1
libusb_get_active_config_descriptor: 0
002/005: 1
libusb_get_active_config_descriptor: 0
002/006: 1
But on Mac OS X it crashes with a segfault:
libusb_init: 0
libusb_get_device_list: 8
Segmentation fault: 11
I have attached the full debug log output to this mail.
This is the backtrace reported by gdb (Line numbers refer to Git
revision e68c66679293a86da62a2636df54b43bbde1daa4):
#0 0x0000000105dae15c in get_configuration_index [inlined] () at
/Users/k.reimer/libusbx/libusb/os/darwin_usb.c:472
#1 0x0000000105dae15c in darwin_get_active_config_descriptor
(dev=0x7fc57be040f0, buffer=0x7fff59e60ae8 "", len=140734701636304,
host_endian=0x7fff59e60ad0) at darwin_usb.c:494
#2 0x0000000105da829e in libusb_get_active_config_descriptor
(dev=0x7fc57be040f0, config=0x7fff59e60b40) at descriptor.c:498
#3 0x0000000105d9fda2 in main ()
The usual beginner question is: Is there something wrong in my code or
is it a libusbx bug? If there is any other info I should provide to find
the problem, please let me know.
--
Bye, K <http://www.ailis.de/~k/>
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
k:~ k.reimer$ ./test1
libusbx: debug [libusb_init] created default context
libusbx: debug [libusb_init] libusbx v1.0.15.10644
libusbx: debug [event_thread_main] creating hotplug event source
libusbx: debug [event_thread_main] thread ready to receive events
libusbx: debug [usbi_add_pollfd] add fd 4 events 1
libusb_init: 0
libusbx: debug [libusb_get_device_list]
libusbx: debug [process_new_device] allocating new device for location
0xfa000000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0200
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x09
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x01
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x40
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x05ac
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0x8006
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x0200
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x02
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x01
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 1 port = 0 parent
= 0x7fb0cb004068 at 0x0
libusbx: debug [process_new_device] allocating new device for location
0xfd000000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0200
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x09
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x01
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x40
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x05ac
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0x8006
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x0200
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x02
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x01
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 1 port = 0 parent
= 0x7fb0cb003338 at 0x0
libusbx: debug [process_new_device] allocating new device for location
0xfa100000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0200
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x09
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x02
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x40
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x0424
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0x2513
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x0bb3
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x00
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x00
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 2 port = 1 parent
= 0x7fb0cb0033f8 at 0x0
libusbx: debug [process_new_device] allocating new device for location
0xfd100000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0200
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x09
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x02
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x40
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x0424
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0x2513
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x0bb3
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x00
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x00
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 2 port = 1 parent
= 0x7fb0c9501378 at 0x0
libusbx: debug [process_new_device] allocating new device for location
0xfa110000
libusbx: debug [darwin_cache_device_descriptor] kernel responded with code:
0xe000404f. sleeping for 30 ms before trying again
libusbx: debug [darwin_cache_device_descriptor] kernel responded with code:
0xe00002ed. sleeping for 30 ms before trying again
libusbx: debug [darwin_cache_device_descriptor] kernel responded with code:
0xe000404f. sleeping for 30 ms before trying again
libusbx: debug [darwin_cache_device_descriptor] could not retrieve device
descriptor 0a5c:4500: pipe is stalled. skipping device
libusbx: debug [libusb_unref_device] destroy device 0.0
libusbx: debug [process_new_device] allocating new device for location
0xfd110000
libusbx: warning [darwin_cache_device_descriptor] could not retrieve device
descriptor 05ac:8242: pipe is stalled. skipping device
libusbx: debug [libusb_unref_device] destroy device 0.0
libusbx: debug [process_new_device] allocating new device for location
0xfa120000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0200
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x046d
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0xc05b
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x5400
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x01
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x02
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 5 port = 2 parent
= 0x7fb0c9407c38 at 0x0
libusbx: debug [process_new_device] allocating new device for location
0xfa113000
libusbx: warning [darwin_cache_device_descriptor] could not retrieve device
descriptor 05ac:8281: device not responding. skipping device
libusbx: debug [libusb_unref_device] destroy device 0.0
libusbx: debug [process_new_device] allocating new device for location
0xfd130000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0200
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x046d
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0xc03d
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x2000
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x01
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x02
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 5 port = 3 parent
= 0x7fb0cb0041c8 at 0x0
libusbx: debug [process_new_device] allocating new device for location
0xfd120000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0110
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x046a
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0x0001
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x0909
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x00
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x00
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 4 port = 2 parent
= 0x7fb0c9501268 at 0x0
libusbx: debug [process_new_device] allocating new device for location
0xfa130000
libusbx: debug [darwin_cache_device_descriptor] device descriptor:
libusbx: debug [darwin_cache_device_descriptor] bDescriptorType: 0x01
libusbx: debug [darwin_cache_device_descriptor] bcdUSB: 0x0110
libusbx: debug [darwin_cache_device_descriptor] bDeviceClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceSubClass: 0x00
libusbx: debug [darwin_cache_device_descriptor] bDeviceProtocol: 0x00
libusbx: debug [darwin_cache_device_descriptor] bMaxPacketSize0: 0x08
libusbx: debug [darwin_cache_device_descriptor] idVendor: 0x413c
libusbx: debug [darwin_cache_device_descriptor] idProduct: 0x2106
libusbx: debug [darwin_cache_device_descriptor] bcdDevice: 0x0155
libusbx: debug [darwin_cache_device_descriptor] iManufacturer: 0x01
libusbx: debug [darwin_cache_device_descriptor] iProduct: 0x02
libusbx: debug [darwin_cache_device_descriptor] iSerialNumber: 0x00
libusbx: debug [darwin_cache_device_descriptor] bNumConfigurations: 0x01
libusbx: debug [darwin_check_configuration] active config: 1, first config: 1
libusbx: debug [process_new_device] found device with address 4 port = 3 parent
= 0x7fb0c9407cf8 at 0x0
libusb_get_device_list: 8
libusbx: debug [libusb_get_active_config_descriptor]
Segmentation fault: 11
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel