Opened 5 years ago
Closed 5 years ago
#18686 closed defect (invalid)
CloseHandle() on WinUSB device hangs until device disconnect
| Reported by: | fenugrec | Owned by: | |
|---|---|---|---|
| Component: | USB | Version: | VirtualBox 6.0.8 |
| Keywords: | closehandle winusb | Cc: | |
| Guest type: | Windows | Host type: | Linux |
Description
Hi, I'm getting a strange USB issue on an XP VM, running in 6.08 on an artix-x64 linux box. (tried both the community and the Oracle-branded (6.0.8 r130520) versions, no change).
I'm writing software (attached is the most reduced test case) that uses winusb to talk to a "candlelight" USB-CAN interface, via this library : https://github.com/HubertD/cangaroo/tree/master/src/driver/CandleApiDriver/api
The "problematic" code is at https://github.com/HubertD/cangaroo/blob/master/src/driver/CandleApiDriver/api/candle.c#L351
Everything looks fine there : call WinUsb_Free(), then CloseHandle().
Note, I didn't write that library so I'm fairly confident it should work.
When I run my test code, it successfully opens the USB device but when I get to that CloseHandle(), the program hangs completely. If I "disconnect" the usb device (through the Devices->Usb->... menu), CloseHandle() completes normally and the program exits cleanly.
I have tried both with "USB 1.1" and "USB 2.0" modes, no change.
Attached is the VM log, and the minimal test harness that essentially just opens then closes the USB device.
I wasn't able to get a proper API trace to winusb.dll, but it goes something like this:
***** "manual" call trace WinUsb_Initialize WinUsb_QueryInterfaceSettings WinUsb_QueryPipe WinUsb_SetPipePolicy (some more initial config) Prepare 30 URBs with CreateEvent and WinUsb_ReadPipe() CloseHandle on all events WinUsb_Free CloseHandle on device *****
Any ideas to isolate the problem more ? I realize it's going to be difficult to reproduce the problem unless someone has access to that hardware, or a STM32F072 eval kit (firmware is open source and compatible).
Thanks, Chris
Attachments (2)
Change History (5)
by , 5 years ago
| Attachment: | winusb_closehandle.log added |
|---|
comment:2 by , 5 years ago
My bad, the library I was using didn't call CancelIO before CloseHandle(). I found a fix in one of the project's un-merged PRs...
This can be closed, I don't have permissions to do so.
Thanks, C
comment:3 by , 5 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |


Machine log