libusb occasionally hangs after suspend/resume
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libusb (Debian) |
New
|
Unknown
|
|||
libusb (Ubuntu) |
New
|
Medium
|
Unassigned |
Bug Description
I'm trying to make g15daemon correctly recover after suspend/resume and found that it occasionally hangs after resume in libusb's usb_urb_transfer() (linux.c) on this line:
ioctl(dev->fd, IOCTL_USB_REAPURB, &context);
After some research I found that linux kernel internally has lists of pending and completed requests. All requests - successful or not - are moved from pending list to completed list, no requests should be lost. But it looks like after suspend/resume some request may be lost (may be a kernel bug). It that case IOCTL_USB_REAPURB would hang forever since request it's waiting for will never appear on completed list.
There is simple workaround. After preceding IOCTL_USB_
I've attached patch with this workaround. It also fixes race condition existed in original code, which may cause corruption of stack.
ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: libusb-0.1-4 2:0.1.12-25 [modified: lib/x86_
ProcVersionSign
Uname: Linux 3.19.0-16-generic x86_64
NonfreeKernelMo
ApportVersion: 2.17.2-0ubuntu1
Architecture: amd64
CurrentDesktop: KDE
Date: Sun May 17 13:11:00 2015
Dependencies:
gcc-5-base 5.1~rc1-0ubuntu1
libc6 2.21-0ubuntu4
libgcc1 1:5.1~rc1-0ubuntu1
multiarch-support 2.21-0ubuntu4
SourcePackage: libusb
UpgradeStatus: Upgraded to vivid on 2015-04-26 (21 days ago)
Related branches
- Steve Langasek: Disapprove
-
Diff: 873 lines (+817/-2)6 files modified.pc/12_hang_after_resume.diff/linux.c (+742/-0)
.pc/applied-patches (+1/-0)
debian/changelog (+7/-0)
debian/patches/12_hang_after_resume.diff (+47/-0)
debian/patches/series (+1/-0)
linux.c (+19/-2)
summary: |
- libusb occasionally hungs after suspend/resume + libusb occasionally hangs after suspend/resume |
description: | updated |
Changed in libusb (Ubuntu): | |
importance: | Undecided → Medium |
Changed in libusb (Debian): | |
status: | Unknown → New |
Please note that debug message about lost URB is not 100% accurate in multi-threaded code because of harmless race condition.