[transport] usb: Fix htool crash on USB disconnect - #249
Merged
Conversation
xorptr
reviewed
May 2, 2026
wak-google
force-pushed
the
libusb-transport
branch
from
May 5, 2026 08:35
8aa623a to
1abb684
Compare
Collaborator
Author
|
Should be fixed up now |
xorptr
reviewed
May 20, 2026
wak-google
force-pushed
the
libusb-transport
branch
from
June 30, 2026 07:16
1abb684 to
416c0ea
Compare
wak-google
force-pushed
the
libusb-transport
branch
from
July 23, 2026 23:50
416c0ea to
448fd16
Compare
stevenportley
approved these changes
Jul 24, 2026
xorptr
approved these changes
Jul 24, 2026
wak-google
force-pushed
the
libusb-transport
branch
from
July 27, 2026 19:47
448fd16 to
c883fa4
Compare
Previously, libhoth_usb_fifo_run_transfers() could return while one or more libusb transfers were still pending. This happened if the second transfer submission failed, or if the event handling loop was interrupted by a signal (e.g. SIGINT). When htool subsequently attempted to close and reopen the transport, it would call libusb_free_transfer() on these pending transfers, triggering an assertion failure in libusb: 'usbi_mutex_lock: Assertion pthread_mutex_lock(mutex) == 0 failed' This change ensures that: 1. All submitted transfers are completed (success, error, or cancel) before the function returns. 2. If a transfer submission fails, any other successfully submitted transfer is cancelled and waited for. 3. Signal interruptions do not cause an early return while transfers are pending. 4. Completion flags are correctly initialized on open. Verified on yutulis-ru4-bmc-01 with 1000 iterations of target reset spam without a crash. Signed-off-by: William A. Kennington III <wak@google.com>
wak-google
force-pushed
the
libusb-transport
branch
from
July 27, 2026 20:09
c883fa4 to
559b8cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, libhoth_usb_fifo_run_transfers() could return while one or more libusb transfers were still pending. This happened if the second transfer submission failed, or if the event handling loop was interrupted by a signal (e.g. SIGINT).
When htool subsequently attempted to close and reopen the transport, it would call libusb_free_transfer() on these pending transfers, triggering an assertion failure in libusb:
'usbi_mutex_lock: Assertion pthread_mutex_lock(mutex) == 0 failed'
This change ensures that:
Verified on yutulis-ru4-bmc-01 with 1000 iterations of target reset spam without a crash.