hidapi icon indicating copy to clipboard operation
hidapi copied to clipboard

Mac: hid_exit() crasher on bad access 0

Open satzg opened this issue 11 years ago • 6 comments

Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 13 at address: 0x0000000000000000 [Switching to process 61712 thread 0x1703] 0x00007fff89770697 in CFSetGetValue () (gdb) bt #0 0x00007fff89770697 in CFSetGetValue () #1 0x00007fff8977e5f0 in __CFRunLoopFindMode () #2 0x00007fff8978d0f5 in CFRunLoopRemoveSource () #3 0x00007fff8d1754f9 in IOHIDDeviceUnscheduleFromRunLoop () #4 0x00007fff8d1771bc in __IOHIDManagerDeviceApplier () #5 0x00007fff897582d2 in __CFSetApplyFunction_block_invoke_1 () #6 0x00007fff89758121 in CFBasicHashApply () #7 0x00007fff897580a4 in CFSetApplyFunction () #8 0x00007fff8d17739f in IOHIDManagerUnscheduleFromRunLoop () #9 0x00007fff8d17740d in IOHIDManagerClose () #10 0x000000010002e49b in hid_exit () at hid.c:393

hid_close is called prior to hid_exit. Completely reproducible.

satzg avatar Dec 09 '12 06:12 satzg

Which version? Using latest from git repo? Can you isolate which version this problem started in?

signal11 avatar Dec 11 '12 18:12 signal11

Encountering this same issue with the latest version. Was it solved?

sharppoin avatar Jul 28 '21 13:07 sharppoin

This is not the repo of the latest version. This is https://github.com/libusb/hidapi See https://github.com/signal11/hidapi/issues/468

todbot avatar Jul 28 '21 14:07 todbot

I understand that this is not the latest. I am using the latest as you linked above. However, I MAY have stumbled upon a "fix", add a 200ms delay between IOHIDManagerClose and CFRelease in the hid_exit method seems to work for me.

sharppoin avatar Jul 29 '21 01:07 sharppoin

In the hid_exit for mac/hid.c (libusb/hidapi), we call IOHIDManagerClose, but there isn't a corresponding IOHIDManagerOpen anywhere in the code except in main()

sharppoin avatar Jul 29 '21 06:07 sharppoin

https://github.com/libusb/hidapi/blob/8741697359b8dd0d73702a69c54e64ffc552d3cf/mac/hid.c#L321

Youw avatar Jul 29 '21 08:07 Youw