-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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_claim_interface crash when device unplug #1366
Comments
Thanks for the report. Can you please try to copy-paste the text from the stack trace? |
Is this on a virtual machine? |
sorry, it was a PC with M1 CPU |
Please give as much information as you can. See https://github.com/libusb/libusb/wiki/Troubleshooting |
I use libusb with Version 1.0.26 release in MAC Version 13.4. I try twenty more to reproduce the BUG,but it do not happend again. |
There has been some fixes for hotplug and darwin fixes since 1.0.26, but they are mostly about exit and not detach. Anyway I'd suggest you try 1.0.27-rc1. Also, your source snippet predates 1.0.24. |
@hjelmn Do you think there can possibly be a claim on the NULL'ed device? |
Please help to try out libusb-1.0.27-rc1 as suggested. Thanks. |
I think this is the cause of the problem,I have two apps. One app is reset devcie, the other app use the old device ,when reset ,so it revice a detached event and set old device to NULL , so I have a question why use as flow,but no use darwin_deref_cached_device(old_device);
I use the libusb-1.0.27-rc1, It happend again the stack as flow
|
also crash as follow when I init my app when another app reset device for detach:`
this may be I have alloc a new device get device info ,the cnt ==1 but it detach and release cnt -- |
here is my patch |
This looks a lot like #1386 I'm quite sure there are threading bugs with the hotplug thread and am investigating it... |
Just wondering if you have a simple test code for my to reproduce the issue. Thanks. Please also take a look at the comments from @seanm about your proposed patch here. Thanks. |
it's my mistake the lock twice, just unlock, I test patch in my program, every thing is ok ,I will correct my patch and push a merge request |
here my patch |
PR will be welcome. Thanks. Please help to mention the steps to reproduce the issue. If it is possible, please post a simple test application to demonstrate the problem. |
I would be very surprised if this bug is different from #1386. |
@benbryantzoro1 Can you please test again with latest git master? |
@tormodvolden and @hjelmn Looks like this issue is not the same as #1386. I can reproduce the issue by running hotplugtest and then unplug the device. Initially no USB devices was attached. Then I plug in the USB hub (with one USB device attached), then I unplug the USB hub, which will casue the crash.
|
As I've said elsewhere, there are numerous threading bugs that still exist. Thread Sanitizer exposes some of them, so does -Wthread-safety. Once 1.0.27 is out, and more of my PRs are merged, I'll continue #1419, which will hopefully help. |
Unfortunately the patch proposed by @benbryantzoro1 does not seem to work.
With Address Sanitizer.
|
@tormodvolden @seanm and @hjelmn On the other hand, this issue exists in libusb-1.0.26 as well so it is not a regression. I just port the hotplugtest.c example from git to 1.0.26 and it has the same crash issue.
|
If I just unplug the attached USB device on the external HUB, then no issues. The following is with git main without any extra patches.
The issue only appears if I unplug the external hub.
|
It seems to me my issue is different from the original posted issue as the crash is different. I will create another issue about hotplugtest crash under macOS. |
Just wondering if you can try out the following test branch which seems to fix #1445. Thanks. Edit: this is no longer required as PR #1452 has been raised which sorted out Issue #1366. It will be great that you can check PR #1452 as well. Thanks. |
If you got the time, please give PR #1452 a try. Thanks. |
Hi, I am in vacation, No device get with me, I will test this as soon as possible I back to work |
I think it have fixed, I use the newest code of libusb with the PR, the BUG no reproduce, I try 20 times |
What I don't understand is that #1452, which supposedly fixes this issue, only changes hotplug_exit() which is called in libusb_exit(), whereas this issue happens on device unplug, without/before libusb_exit() being called. But there is not enough information provided here to exclude that the poster's program actually calls libusb_exit at the same time. (hotplug_exit() is also called on a failed libusb init.) mcuee's crash OTOH clearly happens in libusb_exit(). |
warning: libusb: warning [darwin_open] USBDeviceOpen: another process has device opened for exclusive access
error: libusb: error [darwin_reenumerate_device] USBDeviceReEnumerate: no connection to an IOService
The text was updated successfully, but these errors were encountered: