VirtualBox

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)

winusb_closehandle.log (75.0 KB ) - added by fenugrec 5 years ago.
Machine log
usbtest.c (1.0 KB ) - added by fenugrec 5 years ago.
test case

Download all attachments as: .zip

Change History (5)

by fenugrec, 5 years ago

Attachment: winusb_closehandle.log added

Machine log

by fenugrec, 5 years ago

Attachment: usbtest.c added

test case

comment:1 by fenugrec, 5 years ago

For completeness, I tried with a win7 VM : no change.

comment:2 by fenugrec, 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 aeichner, 5 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy