Skip to content

Crash: EXC_BAD_ACCESS in Combine Debounce handler while deallocating dictionary (0.11.4, macOS 26.6.2, Apple Silicon) #1384

Closed

Description

@ako4711

OS

macOS 26.6.2 (Build 25G83), Mac mini M4 (Apple Silicon)

LinearMouse

v0.11.4

Describe the bug

LinearMouse 0.11.4 crashes with EXC_BAD_ACCESS (SIGSEGV) on the main thread. It has happened twice within three days, both times with a byte-for-byte identical stack trace, including identical binary offsets. Both crashes happened while the machine was idle and unattended. The app does not restart itself, so it stays dead until manually relaunched — in both cases that was the next morning, roughly 20 hours later.

Environment

  • Pointing device: Logitech MX Master 3S over Bluetooth LE (vendorID 0x46d, productID 0xb034)
  • Keyboard: Apple Magic Keyboard with Touch ID (Bluetooth), Display: Apple Studio Display (USB)
  • No other pointer-modifying software installed (no Mac Mouse Fix, no Logitech Options+)
  • Machine uptime 10 days, no reboots or abnormal sleep around either crash

Occurrences

When Context
Fri 2026-09-04, 17:00:37 machine idle, user away
Sun 2026-09-06, 11:18:44 machine idle, user away

Crash

Exception: EXC_BAD_ACCESS (SIGSEGV)
Subtype:   KERN_INVALID_ADDRESS at 0xad205f34ae31ccf5   (2026-09-04)
           KERN_INVALID_ADDRESS at 0x6bf2c9324ae7e469   (2026-09-06)
Thread:    0, queue com.apple.main-thread

Both fault addresses are garbage rather than plausible pointers, which points at an over-release / use-after-free rather than a null dereference.

Stack (identical in both reports)

 0  libswiftCore.dylib   _swift_release_dealloc
 1  libswiftCore.dylib   swift::RefCounts<swift::RefCountBitsT<...>>::doDecrementSlow
 2  LinearMouse          <LinearMouse+311932>
 3  LinearMouse          <LinearMouse+312104>
 4  libswiftCore.dylib   _swift_release_dealloc
 5  libswiftCore.dylib   swift::RefCounts<swift::SideTableRefCountBits>::doDecrementSlow
 6  libswiftCore.dylib   _DictionaryStorage.deinit
 7  libswiftCore.dylib   _DictionaryStorage.__deallocating_deinit
 8  libswiftCore.dylib   _swift_release_dealloc
 9  libswiftCore.dylib   swift::RefCounts<swift::RefCountBitsT<...>>::doDecrementSlow
10  LinearMouse          <LinearMouse+1107408>
11  LinearMouse          <LinearMouse+1106028>
12  Combine              Subscribers.Sink.receive(_:)
13  Combine              protocol witness for Subscriber.receive(_:) in conformance Subscribers.Sink
14  Combine              closure #1 in Publishers.Debounce.Inner.receive(_:)
15  Foundation           partial apply for closure #1 in NSRunLoop.schedule(after:interval:...)
16  Foundation           thunk for @escaping @callee_guaranteed @Sendable (@guaranteed NSTimer) -> ()
17  Foundation           __NSFireTimer

Bottom-up: an NSTimer fires on the run loop, driving a Publishers.Debounce, whose Sink calls into LinearMouse. That handler releases a dictionary; while _DictionaryStorage.deinit tears down its contents, releasing one of the held objects hits an invalid address.

The identical offsets across two independent crashes (+311932, +312104, +1107408, +1106028) indicate one specific code path rather than random memory corruption.

Hypothesis

Both crashes happened while the machine was unattended — exactly when a Bluetooth mouse powers down, disconnects, or re-associates. If device-change notifications are debounced and then used to rebuild a dictionary of connected devices, a device object could be released while another reference to it is still being torn down, producing this over-release. I could not reproduce it on demand, so this is inference from the stack and the timing, not a confirmed cause.

Configuration

Single scheme, filtered to the specific device:

"if": [{ "device": { "category": "mouse", "vendorID": "0x46d",
                     "productID": "0xb034", "productName": "MX Master 3S M" } }]

Active sections: buttons (button mappings incl. modifier+scroll actions), logitech, pointer (hardwareDPI: 1200), scrolling (smooth scrolling enabled, inertia: 0.74, bouncing: true).

Both full .ips crash reports and the complete linearmouse.json are available on request.

To reproduce

I have not found a way to trigger this deliberately. What is known about both occurrences:

  1. Run LinearMouse 0.11.4 on macOS 26.6.2 (Apple Silicon) with a single device-filtered scheme for a Logitech MX Master 3S connected over Bluetooth LE.
  2. Leave the machine idle and unattended for a longer period, so the mouse powers down / disconnects and later re-associates.
  3. LinearMouse is gone on return; a crash report with the stack above is in ~/Library/Logs/DiagnosticReports.

Two occurrences in three days, both while unattended, never once during active use.

Expected behavior

LinearMouse keeps running across mouse disconnect/reconnect cycles instead of crashing.

Secondary: if a crash does happen, it would help a lot if the app came back automatically — right now all button mappings and scrolling behaviour are silently gone until the user notices and relaunches manually, which in my case took about 20 hours.

Anything else?

LinearMouse20260904170037.txt
LinearMouse20260906111844.txt

Activity

  1. added
    bug
    on Sep 7, 2026
  2. ako4711 commented on Sep 28, 2026

    @ako4711
    Author

    Follow-up: the crash keeps recurring after updating to macOS 26.7 (25G229), still on LinearMouse 0.11.4 (binary UUID f0c6bc75-8282-3a3f-b65e-0240379efc6b).

    Three more crashes since the original report: 2026-09-18 (report no longer available), 2026-09-23 15:58 and 2026-09-25 09:31. Both remaining reports are attached.

    Both new reports are identical to each other, and they fault at the same LinearMouse frames as the two crashes in the original report:

    • EXC_BAD_ACCESS (SIGSEGV), KERN_INVALID_ADDRESS with a different garbage address each time
    • main thread, _swift_release_dealloc → LinearMouse +0x4c27c (311932) → LinearMouse +0x4c328 (312104)

    Differences from the original reports: the object being released is now a _ContiguousArrayStorage (array) instead of a _DictionaryStorage, and the Debounce subscriber is reached via Publishers.ReceiveOn / NSRunLoop.schedule(options:) instead of the timer path:

    swift_release_dealloc
    LinearMouse +0x4c27c
    LinearMouse +0x4c328
    swift_arrayDestroy / ContiguousArrayStorage.__deallocating_deinit
    assignWithTake for ClosedRange<>.Index
    Publishers.Debounce.Inner.receive(
    :)
    Publishers.ReceiveOn.Inner.receive(
    :) closure
    NSRunLoop.schedule(options:_:) closure
    __CFRunLoopDoBlocks

    The crashes occurred 6.3 and 7.5 hours after the last wake, so they don't seem to be tied to sleep/wake itself. That still fits the idea of the Bluetooth mouse (MX Master 3S) disconnecting and reconnecting while the machine sits idle.

    LinearMouse-2026-09-25-093111.txt

    LinearMouse-2026-09-23-155847.txt

  3. lujjjh commented on Oct 3, 2026

    @lujjjh
    Collaborator

    Thanks for the report! A fix for potential crashes when mice connect or disconnect was included in v0.12.0-beta.5 and is also available in the latest release, v0.12.0. Please update and let me know if the crash happens again.

  4. ako4711 commented on Oct 19, 2026

    @ako4711
    Author

    No new crashes since 2 weeks and update to v0.12.0. Thanks for your help. Problem solved

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions