You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MacOSX 10.12: Library crashes when unplug device just at the right time #337
Seems to me that the IOKit it's not doing a great job on handling the Source's RunLoop execution (due to a possible incoming report) when the device has been removed from the System.
I'm not sure how to prevent this collision if the Source it's been executed (just at the right time) when the device it's been removed.
Any ideas of how to synchronize/workaround this are more than welcome, thanks.
NOTE: My App as you can tell from the stack trace, it's running inside of a JVM.
@tresf thanks for the info. Unfortunately that specific fix addresses a crash during hid_enumerate() (stack from the issue qzind/tray#137 (comment)):
Stack: [0x000070000de54000,0x000070000df54000], sp=0x000070000df51580, free space=1013k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [CoreFoundation+0x55554] CFSetGetValue+0x24
C [CoreFoundation+0x550b5] __CFRunLoopFindMode+0xc5
C [CoreFoundation+0x55889] CFRunLoopAddSource+0xc9
C [IOKit+0x3726f] IOHIDDeviceScheduleWithRunLoop+0x66
C [IOKit+0x3983a] __IOHIDManagerDeviceApplier+0x1e8
C [IOKit+0x3a7e2] __IOHIDManagerDeviceAdded+0x153
C [IOKit+0x39cf0] __IOHIDManagerSetDeviceMatching+0xff
C [jna4455466734030689331.tmp+0x1328] hid_enumerate+0xc8
C [jna8427230249487447742.tmp+0xe134] ffi_call_unix64+0x4c
C 0x000070000df52dd8
And the one I'm experiencing it's inside the read_thread() when unplugging an active device. The device's Source (IOKit code) inside the RunLoop encounters something NULL and blows up. My problem is how to influence this behavior at the hidapi layer, attempted to sync the RunLoopStop, changed from CFRunLoopRunInMode to Default, modified read_thread to basically only move the device to the thread's runLoop + register the report_callback + call and block with CFRunLoopRun + cleanup and return. And none of these options prevent the crash inside the IOKit routine execution of this device's source. I do believe they should have some protection to 'know' when the device was disconnected and don't attempt to process another report, right?
Activity
tresf commentedon Jun 8, 2017
@chalio168ti If you're doing this from Java, you may want to look at this thread... qzind/tray#137 (comment)
chalio168ti commentedon Jun 9, 2017
@tresf thanks for the info. Unfortunately that specific fix addresses a crash during hid_enumerate() (stack from the issue qzind/tray#137 (comment)):
And the one I'm experiencing it's inside the read_thread() when unplugging an active device. The device's Source (IOKit code) inside the RunLoop encounters something NULL and blows up. My problem is how to influence this behavior at the hidapi layer, attempted to sync the RunLoopStop, changed from CFRunLoopRunInMode to Default, modified read_thread to basically only move the device to the thread's runLoop + register the report_callback + call and block with CFRunLoopRun + cleanup and return. And none of these options prevent the crash inside the IOKit routine execution of this device's source. I do believe they should have some protection to 'know' when the device was disconnected and don't attempt to process another report, right?
Update 69-hid.rules (signal11#337)