Skip to content

The test run crashes when a package library outlives its bar #480

Closed

Description

@M4n0x

What happens

swift test sometimes aborts with Fatal error: Attempted to read an unowned reference but the object was already destroyed (signal 6), which ends the whole Swift Testing run. It has failed 7 CI runs since 2026-10-23, including pushes to main on 10-28, 10-31, 11-04 and 11-07; a red main push publishes no beta. It also crashed a local run on 2026-11-08.

Steps to reproduce

In a test: create a BarStore, keep its packageLibrary, release the store, then run the library's update work with await library.loadInstalled(). It aborts in PackageLibrary.syncSources() every time.

On CI it takes a test whose store started at least 15 seconds earlier and that ends while the update check waits for its client, which only happens on a busy runner.

Expected

A package library that outlives its bar skips the work that needs the bar, without crashing.

Environment

CI (macos-26, Xcode 26.6, Swift 6.3.3) and a local run (macOS 27.2, Xcode 27.2, Swift 6.4.2). The app keeps one BarStore for as long as it runs, so this is unlikely to reach people using the bar; it breaks test runs.

Evidence

Local crash report, main thread:

swift::swift_abortRetainUnowned(void const*)
swift_unknownObjectUnownedLoadStrong
PackageLibrary.syncSources()                      PackageLibrary.swift:370
PackageLibrary.configurationChanged()             PackageLibrary.swift:348
PackageLibrary.loadInstalled()                    PackageLibrary.swift:392
closure in PackageLibrary.startUpdateChecks()     PackageLibrary.swift:101

CI runs that crashed this way: 39972162112, 40309333232, 40674033525, 41084374463, 41218427956, 41826138923, 42375992589.

Diagnosis

PackageLibrary holds private unowned let store: BarStore (Sources/StableBar/PackageLibrary.swift:36), which promises that the store outlives the library. It doesn't always:

  • BarStore.start() calls packageLibrary.startUpdateChecks(), whose timer fires after 15 seconds, then hourly. Its task holds the library while it waits for client.installed(). When the store is released meanwhile, loadInstalled() resumes into configurationChanged() and syncSources(), which read the destroyed store.
  • PackagesView keeps a library in @State, which can also outlive the store.

WidgetPopup already holds its store weakly (private weak var store: BarStore?).

Related

Triaged by Claude Code (Claude Opus 5.5).

Activity

  1. added
    bug
    on Nov 8, 2026
  2. stablebar-releases commented on Nov 10, 2026

    @stablebar-releases

    🎉 This issue has been resolved in version 0.12.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