SANE vs USB scanner on 8.0

Daniel O'Connor doconnor at gsoft.com.au
Wed Sep 30 14:12:02 UTC 2009


On Mon, 28 Sep 2009, Hans Petter Selasky wrote:

> -       if (sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2)
> +       if ((sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2) &&
> +           (sscanf(dev, "libusb:/dev/usb:ugen%d.%d", &busnum,
> &devnum) != 2)) {
>             DBG (DL_MAJOR_ERROR, "%s: could not parse device string:
> %s\n", me, strerror(errno));
>             return 0;
>
> If it works, get the patch sent to the sane developers.

Unfortunately no (I reworked it to match the path it uses) and now it 
segfaults. I rebuilt sane with debugging (is there some way to make libtool
not strip on install? It's so tedious manually editing makefiles to remove
-s..) as well as libusb.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 801b021c0 (LWP 100292)]
0x000000080140e715 in libusb20_dev_open (pdev=0x801b13d00, nTransferMax=32)
    at /usr/src/lib/libusb/libusb20.c:550
550             error = pdev->beMethods->open_device(pdev, nTransferMax);
(gdb) bt
#0  0x000000080140e715 in libusb20_dev_open (pdev=0x801b13d00, nTransferMax=32)
    at /usr/src/lib/libusb/libusb20.c:550
#1  0x0000000801408f15 in usb_open (dev=0x801b1ae00)
    at /usr/src/lib/libusb/libusb20_compat01.c:150
#2  0x000000080065c34f in sanei_usb_open (
    devname=0x801b09380 "libusb:/dev/usb:/dev/ugen0.5", dn=0x7fffffffdc0c)
    at sanei_usb.c:1143
#3  0x00000008025e5ad3 in snapscani_usb_open (
    dev=0x801b09380 "libusb:/dev/usb:/dev/ugen0.5", fdp=0x7fffffffdc0c,
    sense_handler=0x8025df7c0 <sense_handler>, pss=0x0) at snapscan-usb.c:178
#4  0x00000008025eb985 in add_usb_device (
    full_name=0x801b09080 "libusb:/dev/usb:/dev/ugen0.5") at snapscan.c:590
#5  0x000000080065c0ed in sanei_usb_find_devices (vendor=1189, product=8288,
    attach=0x8025eb880 <add_usb_device>) at sanei_usb.c:1091
#6  0x000000080065bb3e in sanei_usb_attach_matching_devices (name=0x7fffffffdcc1 "",
    attach=0x8025eb880 <add_usb_device>) at sanei_usb.c:965
#7  0x00000008025ebdac in sane_snapscan_init (version_code=0x7fffffffe0f8,
    authorize=0x401b50 <auth_callback>) at snapscan.c:735
#8  0x000000080066579b in init (be=0x801b0da00) at dll.c:613
#9  0x000000080066621b in sane_dll_get_devices (device_list=0x7fffffffea00,
---Type <return> to continue, or q <return> to quit---
    local_only=0) at dll.c:1034
#10 0x0000000800658bbb in sane_get_devices (dl=0x7fffffffea00, local=0) at dll-s.c:17
#11 0x0000000000405a11 in main (argc=4, argv=0x7fffffffeb30) at scanimage.c:1771
(gdb) print *pdev
$1 = {ddesc = {LIBUSB20_DEVICE_DESC_FORMAT = 0x0, bLength = 0 '\0',
    bDescriptorType = 0 '\0', bcdUSB = 0, bDeviceClass = 0 '\0',
    bDeviceSubClass = 0 '\0', bDeviceProtocol = 0 '\0', bMaxPacketSize0 = 0 '\0',
    idVendor = 0, idProduct = 0, bcdDevice = 0, iManufacturer = 0 '\0',
    iProduct = 0 '\0', iSerialNumber = 0 '\0', bNumConfigurations = 0 '\0'},
  session_data = {session_data = 0, tv = {tv_sec = 0, tv_nsec = 0}, plugtime = 0},
  dev_entry = {tqe_next = 0x0, tqe_prev = 0x0}, methods = 0x0, beMethods = 0x0,
  pTransfer = 0x801b48500, privBeData = 0x0, privLuData = 0x0,
  claimed_interface = 0 '\0', file = 0, file_ctrl = 0, debug = 0, nTransfer = 32,
  bus_number = 0 '\0', device_address = 0 '\0', usb_mode = 0 '\0',
  usb_speed = 0 '\0', is_opened = 0 '\0', usb_desc = '\0' <repeats 95 times>}
(gdb) up
#1  0x0000000801408f15 in usb_open (dev=0x801b1ae00)
    at /usr/src/lib/libusb/libusb20_compat01.c:150
150             err = libusb20_dev_open(dev->dev, 16 * 2);
(gdb) print *dev
$2 = {next = 0x0, prev = 0x0, filename = "/dev/ugen0.5", '\0' <repeats 1012 times>,
  bus = 0x801510020, descriptor = {bLength = 18 '\022', bDescriptorType = 1 '\001',
    bcdUSB = 256, bDeviceClass = 255 'ÿ', bDeviceSubClass = 255 'ÿ',
    bDeviceProtocol = 255 'ÿ', bMaxPacketSize0 = 8 '\b', idVendor = 1189,
    idProduct = 8288, bcdDevice = 256, iManufacturer = 1 '\001',
    iProduct = 2 '\002', iSerialNumber = 0 '\0', bNumConfigurations = 1 '\001'},
  config = 0x801b23280, dev = 0x801b13d00, devnum = 0 '\0', num_children = 0 '\0',
  children = 0x0}
(gdb) print dev->dev
$3 = (void *) 0x801b13d00
(gdb) up
#2  0x000000080065c34f in sanei_usb_open (
    devname=0x801b09380 "libusb:/dev/usb:/dev/ugen0.5", dn=0x7fffffffdc0c)
    at sanei_usb.c:1143
1143          devices[devcount].libusb_handle =
(gdb) list
1138    #ifdef HAVE_LIBUSB
1139          struct usb_device *dev;
1140          struct usb_interface_descriptor *interface;
1141          int result, num;
1142
1143          devices[devcount].libusb_handle =
1144            usb_open (devices[devcount].libusb_device);
1145          if (!devices[devcount].libusb_handle)
1146            {
1147              SANE_Status status = SANE_STATUS_INVAL;
(gdb) print *devices[devcount].libusb_device
$4 = {next = 0x0, prev = 0x0, filename = "/dev/ugen0.5", '\0' <repeats 1012 times>,
  bus = 0x801510020, descriptor = {bLength = 18 '\022', bDescriptorType = 1 '\001',
    bcdUSB = 256, bDeviceClass = 255 'ÿ', bDeviceSubClass = 255 'ÿ',
    bDeviceProtocol = 255 'ÿ', bMaxPacketSize0 = 8 '\b', idVendor = 1189,
    idProduct = 8288, bcdDevice = 256, iManufacturer = 1 '\001',
    iProduct = 2 '\002', iSerialNumber = 0 '\0', bNumConfigurations = 1 '\001'},
  config = 0x801b23280, dev = 0x801b13d00, devnum = 0 '\0', num_children = 0 '\0',
  children = 0x0}

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freebsd.org/pipermail/freebsd-usb/attachments/20090930/8447f131/attachment.pgp


More information about the freebsd-usb mailing list