Skip to content

Fix crash when Logitech receiver channel fails to open - #1333

Merged
lujjjh merged 1 commit into
linearmouse:mainfrom
ksc98:fix/receiver-channel-open-failure-crash
Aug 7, 2026
Merged

lujjjh merged 1 commit into
linearmouse:mainfrom
ksc98:fix/receiver-channel-open-failure-crash

Conversation

@ksc98

@ksc98 ksc98 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

deinit {} is always called, but its logic should be skipped if the channel didn't get opened.

An example situation in which the channel doesn't get opened: a battery poller happens to hold the interface at open time, so IOHIDDeviceOpen fails with kIOReturnExclusiveAccess

IOHIDDeviceCancel on a never-activated device then aborts the app — hence the crash on startup:

Process:           LinearMouse [72112]
Version:           0.11.4
Launch Time:       2026-08-04 23:38:16.3020 -0700
Crashed:           2026-08-04 23:38:16.6776 -0700   (~0.3 s after launch, as a login item)
Exception Type:    EXC_CRASH (SIGABRT)
Termination:       Application Triggered Fault
Assertion:         Cancel failed queue: %p runLoop: %p

Thread Crashed:
0   libsystem_kernel.dylib   __abort_with_payload
1   libsystem_kernel.dylib   abort_with_payload_wrapper_internal
2   libsystem_kernel.dylib   abort_with_payload
3   libsystem_c.dylib        _os_crash_msg
4   IOKit                    IOHIDDeviceCancel
5   LinearMouse              0xfa9c
6   LinearMouse              0xfba0
7   libswiftCore.dylib       _swift_release_dealloc

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents a startup crash in the Logitech HID++ receiver channel teardown path by avoiding IOHIDDeviceCancel when the HID device was never successfully activated (e.g., when IOHIDDeviceOpen fails with kIOReturnExclusiveAccess).

Changes:

  • Track whether the receiver channel’s IOHIDDevice was activated (isActivated).
  • Guard deinit teardown so cancellation only occurs for activated devices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lujjjh lujjjh added the bug Something isn't working label Aug 7, 2026
@lujjjh
lujjjh merged commit af0713c into linearmouse:main Aug 7, 2026
1 check passed
@lujjjh

lujjjh commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants