Mac: hid_enumerate crash on macOS 14 when linked to AppKit and inside a fork #587
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi#587
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The example code below crashes in macOS 14 on a call to IOHIDManagerCreate when linked against AppKit and the --fork flag is passed. Removing the AppKit dependency allows it to run as expected. I've filed a case with Apple since this seems to be an OS bug.
However it seems that the only reason why the hidapi code needs to be linked against AppKit is because it references NSAppKitVersionNumber to check for if running on macOS >= 10.10 Yosemite
github.com/libusb/hidapi@80e8d62bc1/mac/hid.c (L469)Would it be reasonable to send a pull request that dropped support for macOS < 10.10? This would simplify the code a bit and remove the requirement for linking with AppKit entirely.
I don't think I have enough info to tell if we should drop the 10.10 support
can we instead have compile-time desision based on the
-mmacosx-version-mincompilation flag (I'm not sure if there is corresponding compile-time macro definition - I presume there is)?that should be both safe and backward compatible
Maybe something like
would work?
Unfortunately no. It has to be more like:
and the declaration of
NSAppKitVersionNumberhas to be under similarifdefso is the link library in
CMakeList.txtYes, that's less than ideal. Another option suggested to me was to use
unameto get the Darwin kernel version, which for macOS >= 10.10 would be Darwin >= 14.0.0. Comparing the version strings properly then means extracting out the first dot component of the version string and converting it to an integer. This seems like a lot of extra code just to avoid linking AppKit. I think if continued support for pre 10.10 versions is desired, it's probably fine to close this as infeasible.And what I suggest and will gladely accept if anyone opens a PR.
Yeah, I prefer avoiding such if possiblle.