Skip to content

StableBar crashes reading the menu bar items when macOS lists an app's PID twice #616

Closed

Description

@Jonathanm10

What happens

StableBar quit with EXC_BREAKPOINT (SIGTRAP) while it re-read the macOS menu bar items. The faulting stack:

libswiftCore  _assertionFailure(_:_:file:line:flags:)
StableBar     specialized _NativeDictionary.merge<A>(_:isUnique:uniquingKeysWith:)
StableBar     AppMenu.readMenuBarItems(requestingAccess:)
StableBar     closure #2 in BarStore.readMenuBarItems()

Steps to reproduce

Not reproduced on demand. The crash happened while an app (Dayflow) relaunched itself after it was granted Screen Recording access, which likely made NSWorkspace.shared.runningApplications list the same process identifier twice for a moment. The crash report doesn't say which PID was duplicated, so this trigger is likely but not proven.

Expected

StableBar keeps running and reads the menu bar items, using one app per process identifier.

Environment

  • StableBar 0.15.0-beta.20261113075115.1005 (build 1005)
  • macOS 27.2.1 (26B131), Apple silicon

Evidence

Crash report StableBar-2026-11-13-095219.ips: EXC_BREAKPOINT / SIGTRAP, stack above.

Diagnosis

Sources/StableBar/AppMenu.swift:233 on main maps the running apps by process identifier with Dictionary(uniqueKeysWithValues:), which traps on a duplicate key:

let apps = Dictionary(uniqueKeysWithValues: NSWorkspace.shared.runningApplications
    .filter { $0.processIdentifier != ProcessInfo.processInfo.processIdentifier }
    .map { ($0.processIdentifier, $0) })

Keeping the first app for each process identifier (Dictionary(_:uniquingKeysWith:)) avoids the trap. NativeMetrics.swift builds its CPU-time map by process identifier the same way, and the process list already does this for the running apps a few lines below.

Related

None found: searched open and closed issues and pull requests for crash, duplicate PID, runningApplications, readMenuBarItems and uniqueKeysWithValues. #446 changed which app owns the menu bar items, not this map.

Triaged by Claude Code (Claude Opus 5.5).

Activity

  1. added
    needs-triage
    on Nov 13, 2026
  2. added
    bug
    and removed
    needs-triage
    on Nov 13, 2026
  3. stablebar-releases commented on Nov 14, 2026

    @stablebar-releases

    🎉 This issue has been resolved in version 0.15.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

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

    bugreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions