Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darwin async callback inconsistency: LIBUSB_TRANSFER_NO_DEVICE #1364

Open
fabiensanglard opened this issue Dec 7, 2023 · 1 comment
Open
Labels

Comments

@fabiensanglard
Copy link

Let's say I have a device with an async transfer callback.

On Linux, if I physically disconnect the device, both with an USB2 or USB3 cable, the callback triggers and I see its status is LIBUSB_TRANSFER_NO_DEVICE.

On MacOSX however, if the device is connected via USB2 cable, I see the transfer status is LIBUSB_TRANSFER_ERROR. If the cable used is USB3, I see transfer status LIBUSB_TRANSFER_CANCELLED.

Is it expected behavior?

@fabiensanglard fabiensanglard changed the title Macosx never returns LIBUSB_TRANSFER_NO_DEVICE? Darwin async callback inconsistency: LIBUSB_TRANSFER_NO_DEVICE Dec 7, 2023
@tormodvolden
Copy link
Contributor

I don't think this is the desired behavior. @hjelmn can you comment on this?

jrguzman-ms pushed a commit to msft-mirror-aosp/platform.packages.modules.adb that referenced this issue Dec 13, 2023
Problem: adb server with libusb backend crashes when unplugging a device using an USB3 cable (macosx only). There are two issues at hand here.

First there is bug in libusb (libusb/libusb#1364). Upon detach, the transfer callback should be called with status LIBUSB_TRANSFER_NO_DEVICE but on darwin we get LIBUSB_TRANSFER_CANCELLED.

Second, this Check is wrong anyway. Upon detach, the read callback are triggered BEFORE the hotplug callback so `terminated_` cannot be set to true anyway.

Solution: Remove agressive trap. adb server doesn't crash if the trap
is removed and works normally.

Fixes: 308190337
Test: NA
Change-Id: I8ba10f910b6423e467a1b442aeba1e31c7a6610a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants