Hi, This patch does indeed fix the deadlock condition on libusb_exit(), but unfortunately it opens up another opportunity for deadlock :(
If the hotplug event thread is processing a hotplug event when it is cancelled, there is a chance that it may be cancelled while holding the active_contexts_lock (inside linux_hotplug_enumerate() or linux_hotplug_disconnected()). Granted this is a very small chance, because the active_contexts_list should be empty when the hotplug event thread is being shut down, but it is possible nonetheless. If this occurs, libusb will be unusable from that point forward, since the active_contexts_lock is static. If the application is exiting, no big deal--otherwise, the next call to libusb_init() will hang. The only robust solution would be to gracefully end the hotplug event thread. This can be achieved using the control pipe approach that Toby Gray provided for netlink. pthread_cancel() is in general not very graceful, so I think it would do well to eliminate it. The attached patch, in conjunction with your patch to use two separate locks, should eliminate issues surrounding this. Regards, Chris On Fri, Jul 19, 2013 at 2:19 AM, Hans de Goede <hdego...@redhat.com> wrote: > Hi, > > On 07/19/2013 11:06 AM, Hans de Goede wrote: > > Hi All, > > > > I had some inspiration this morning how to fix the deadlock Chris Dickens > > found as a result of the bugreport I forwarded. > > > > So here is a fix for it. I've asked the bug-reporter to test, see: > > https://bugzilla.redhat.com/show_bug.cgi?id=985484 > > > > While writing this, I noticed that the netlink code was missing a > pthread_join, > > so I've added a 2nd patch adding that. > > > > Note the netlink changes are untested. > > > > And now I'm really really really leaving for vacation (we depart in about > > an hour), see you all in a week! > > p.s. > > I believe that if we get confirmation this fixes things, we should probably > do a 1.0.17 soon-ish to get this fix out there, as it is a rather nasty > bug. > > If you agree, feel free to do such a release while I'm away :) > > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > _______________________________________________ > libusbx-devel mailing list > libusbx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libusbx-devel >
0001-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch
Description: Binary data
------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel