[Bug 256296] "No Device" error after using asynchronous API of libusb once

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 05 Jun 2021 22:30:37 UTC

Sergii <sergii.dmytruk@3mdeb.com> changed:

           What    |Removed                     |Added
 Attachment #225431|0                           |1
        is obsolete|                            |

--- Comment #6 from Sergii <sergii.dmytruk@3mdeb.com> ---
Created attachment 225579
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=225579&action=edit
Better bug reproducer

Made a better example that showcases the bug. No help from debugger is
necessary. Demonstrates the issue 100% runs for me. Device is opened and closed
twice. Second time its opened there is a transfer attempt which always fails
(returns "no device" error).

The API is used properly as far as I can tell and the code "works" if you
remove sleep() calls, but doesn't if you leave them. I'm pretty confident this
is a bug in libusb.

Another suggestion for a fix: before handling an event check whether device is
still in the polling queue and if not, ignore the event. This might be the best
fix because the issue is that device is being polled after it was closed
(background thread was blocked on poll() at that time), so any events from this
device should be rightfully discarded as if it wasn't on the polling queue when
the event has arrived.

You are receiving this mail because:
You are the assignee for the bug.