Ticket #82 (closed defect: fixed)
Opened 2 years ago
Last modified 18 months ago
Crash in timed-out transfer
| Reported by: | www.google.com/accounts/o8/id?id=aitoawmz93igogrpknbehv21jdxrf37ft8ksncg | Owned by: | pbatard |
|---|---|---|---|
| Milestone: | Component: | libusb-1.0 | |
| Keywords: | Cc: | ||
| Blocked By: | Blocks: |
Description
Not sure why I'm seeing this crash spuriously. This is a timeout of an HCI bulk-pipe transfer. This is based on 0816743fe70013739d31bac79017a64c7ceb0055 from Pete Batard's master branch. Also seeing the same thing from Ubuntu 10.10 (libusb 1.0.8-2)
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6a52728 in cancel_control_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1705
1705 usbi_err(TRANSFER_CTX(transfer),
(gdb) bt
#0 0x00007ffff6a52728 in cancel_control_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1705
#1 0x00007ffff6a529c0 in op_cancel_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1767
#2 0x00007ffff6a4d19d in libusb_cancel_transfer (transfer=0x6f8ed8) at ../../libusb/io.c:1309
#3 0x00007ffff6a4d91c in handle_timeout (itransfer=0x6f8e80) at ../../libusb/io.c:1707
#4 0x00007ffff6a4da95 in handle_timeouts_locked (ctx=0x6d0620) at ../../libusb/io.c:1760
#5 0x00007ffff6a4db65 in handle_timerfd_trigger (ctx=0x6d0620) at ../../libusb/io.c:1788
#6 0x00007ffff6a4de72 in handle_events (ctx=0x6d0620, tv=0x7fffffffd960) at ../../libusb/io.c:1878
#7 0x00007ffff6a4e07e in libusb_handle_events_timeout_check (ctx=0x6d0620, tv=0x7fffffffd9c0, completed=0x0) at ../../libusb/io.c:1970
#8 0x00007ffff6a4e143 in libusb_handle_events_timeout (ctx=0x6d0620, tv=0x7fffffffd9c0) at ../../libusb/io.c:2005
(gdb) p *transfer
$1 = {dev_handle = 0x6f6fd0, flags = 0 '00', endpoint = 0 '00', type = 0 '00', timeout = 5000, status = LIBUSB_TRANSFER_COMPLETED, length = 30, actual_length = 0,
callback = 0x4380e7 <usb::deviceio_transfer_finished(libusb_transfer*)>, user_data = 0x6f90b0, buffer = 0x6f9328 " ", num_iso_packets = 0, iso_packet_desc = 0x6f8ed8}
Attachments
Change History
comment:1 Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawmz93igogrpknbehv21jdxrf37ft8ksncg
comment:2 Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawmz93igogrpknbehv21jdxrf37ft8ksncg
Probably related - I can see crashes when running under gdb with breakpoints in handle_control_completion & handle_timeout. I call libusb_get_string_descriptor_ascii quite frequently too. Could it be a race condition?
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6a52728 in cancel_control_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1705
1705 usbi_err(TRANSFER_CTX(transfer),
(gdb) bt
#0 0x00007ffff6a52728 in cancel_control_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1705
#1 0x00007ffff6a529c0 in op_cancel_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1767
#2 0x00007ffff6a4d19d in libusb_cancel_transfer (transfer=0x6f8ed8) at ../../libusb/io.c:1309
#3 0x00007ffff6a4d91c in handle_timeout (itransfer=0x6f8e80) at ../../libusb/io.c:1707
#4 0x00007ffff6a4da95 in handle_timeouts_locked (ctx=0x6d0620) at ../../libusb/io.c:1760
#5 0x00007ffff6a4db65 in handle_timerfd_trigger (ctx=0x6d0620) at ../../libusb/io.c:1788
#6 0x00007ffff6a4de72 in handle_events (ctx=0x6d0620, tv=0x7fffffffd130) at ../../libusb/io.c:1878
#7 0x00007ffff6a4e07e in libusb_handle_events_timeout_check (ctx=0x6d0620, tv=0x7fffffffd170, completed=0x7fffffffd1dc) at ../../libusb/io.c:1970
#8 0x00007ffff6a4e17c in libusb_handle_events_check (ctx=0x6d0620, completed=0x7fffffffd1dc) at ../../libusb/io.c:2014
#9 0x00007ffff6a4ec30 in libusb_control_transfer (dev_handle=0x6f6f10, bmRequestType=128 '200', bRequest=6 '06', wValue=771, wIndex=1033, data=0x7fffffffd280 "0403 04", wLength=255, timeout=1000)
at ../../libusb/sync.c:105
#10 0x00007ffff6a4b373 in libusb_get_string_descriptor (dev=0x6f6f10, desc_index=3 '03', langid=1033, data=0x7fffffffd280 "0403 04", length=255) at ../../libusb/libusb.h:1274
#11 0x00007ffff6a4c684 in libusb_get_string_descriptor_ascii (dev=0x6f6f10, desc_index=3 '03', data=0x7fffffffd3b0 "300325377377377177", length=255) at ../../libusb/descriptor.c:697
Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawkqduuilezm1tu1seo2uz1ndphzkn82lqc
Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawkqduuilezm1tu1seo2uz1ndphzkn82lqc
Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawkqduuilezm1tu1seo2uz1ndphzkn82lqc
Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawkqduuilezm1tu1seo2uz1ndphzkn82lqc
Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawkqduuilezm1tu1seo2uz1ndphzkn82lqc
comment:3 Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawkqduuilezm1tu1seo2uz1ndphzkn82lqc
Attached 6 patches that when all applied should ensure that this won't happen. I suspect the issue here is as a result of the device disappearing (e.g. usb reset) while transfers are pending.
Valgrind reports a similar looking error:
==11780== Invalid read of size 8 ==11780== at 0x646FBA4: discard_urbs (linux_usbfs.c:1362) ==11780== by 0x64707C0: op_cancel_transfer (linux_usbfs.c:1748) ==11780== by 0x646B14D: libusb_cancel_transfer (io.c:1314) ==11780== by 0x646B8CC: handle_timeout (io.c:1712) ==11780== by 0x646BA45: handle_timeouts_locked (io.c:1755) ==11780== by 0x646BB15: handle_timerfd_trigger (io.c:1782) ==11780== by 0x646BE22: handle_events (io.c:1872) ==11780== by 0x646C012: libusb_handle_events_timeout (io.c:1961) ==11780== Address 0xaa51790 is 64 bytes inside a block of size 76 free'd ==11780== at 0x4C27D71: free (vg_replace_malloc.c:366) ==11780== by 0x6468629: do_close (core.c:1025) ==11780== by 0x6468795: libusb_close (core.c:1082)
Changed 2 years ago by www.google.com/accounts/o8/id?id=aitoawkqduuilezm1tu1seo2uz1ndphzkn82lqc
[6/6] v3 - correct condition check logic for printing error messages. doesn't impact actual behaviour.
comment:4 Changed 2 years ago by pbatard
- Owner set to pbatard
- Status changed from new to accepted
comment:5 Changed 21 months ago by Vitali Lovich <vlovich@…>
comment:6 Changed 21 months ago by Vitali Lovich <vlovich@…>
comment:7 Changed 21 months ago by Vitali Lovich <vlovich@…>
comment:8 Changed 21 months ago by Vitali Lovich <vlovich@…>
comment:9 Changed 18 months ago by Vitali Lovich <vlovich@…>
comment:10 Changed 18 months ago by Vitali Lovich <vlovich@…>
comment:11 Changed 18 months ago by Vitali Lovich <vlovich@…>
comment:12 Changed 18 months ago by Vitali Lovich <vlovich@…>
- Resolution set to fixed
- Status changed from accepted to closed
Woops - forgot to format stack trace.
Program received signal SIGSEGV, Segmentation fault. 0x00007ffff6a52728 in cancel_control_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1705 1705 usbi_err(TRANSFER_CTX(transfer), (gdb) bt #0 0x00007ffff6a52728 in cancel_control_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1705 #1 0x00007ffff6a529c0 in op_cancel_transfer (itransfer=0x6f8e80) at ../../libusb/os/linux_usbfs.c:1767 #2 0x00007ffff6a4d19d in libusb_cancel_transfer (transfer=0x6f8ed8) at ../../libusb/io.c:1309 #3 0x00007ffff6a4d91c in handle_timeout (itransfer=0x6f8e80) at ../../libusb/io.c:1707 #4 0x00007ffff6a4da95 in handle_timeouts_locked (ctx=0x6d0620) at ../../libusb/io.c:1760 #5 0x00007ffff6a4db65 in handle_timerfd_trigger (ctx=0x6d0620) at ../../libusb/io.c:1788 #6 0x00007ffff6a4de72 in handle_events (ctx=0x6d0620, tv=0x7fffffffd960) at ../../libusb/io.c:1878 #7 0x00007ffff6a4e07e in libusb_handle_events_timeout_check (ctx=0x6d0620, tv=0x7fffffffd9c0, completed=0x0) at ../../libusb/io.c:1970 #8 0x00007ffff6a4e143 in libusb_handle_events_timeout (ctx=0x6d0620, tv=0x7fffffffd9c0) at ../../libusb/io.c:2005 (gdb) p *transfer $1 = {dev_handle = 0x6f6fd0, flags = 0 '00', endpoint = 0 '00', type = 0 '00', timeout = 5000, status = LIBUSB_TRANSFER_COMPLETED, length = 30, actual_length = 0, callback = 0x4380e7 <usb::deviceio_transfer_finished(libusb_transfer*)>, user_data = 0x6f90b0, buffer = 0x6f9328 " ", num_iso_packets = 0, iso_packet_desc = 0x6f8ed8}