Skip to content

Cancelling a command as it exits can deadlock the bar and tests #364

Closed

Description

@Seb-GRAF

What happens

Cancelling a command while its completion resumes a Swift task can deadlock the main actor. The test suite can then remain stuck until CI cancels the job.

Steps to reproduce

Run the full test suite while command completion and cancellation overlap. This is intermittent. A local full-suite run reproduced it even with swift test --no-parallel.

Expected

Cancellation stops the command and allows the awaiting task to finish without blocking the main actor.

Environment

macOS, Swift 6, current main at 0fe1fed. The local reproduction used the Xcode Swift toolchain.

Evidence

A stack sample of the hung test process showed the main actor inside WorkspaceStore.start, cancelling a task through CommandProcess.cancel. It held a Swift task status lock while waiting in DispatchQueue.sync. The command queue was inside CommandProcess.finish, resuming the continuation and waiting for that same task lock.

PR #353 also has a 20-minute test timeout, but no stack sample was captured on that runner to prove the same cause: https://github.com/Seb-GRAF/StableBar/actions/runs/40657697004

Diagnosis

Sources/StableBar/Command.swift synchronously enters the command queue from the cancellation handler. Enqueuing cancellation asynchronously breaks the lock cycle while keeping process state on its existing serial queue.

Related

#215 and PRs #142 and #156 concern short timing assertions. This is a reproduced production-code deadlock, rather than a slow-runner assertion failure. Searches of issues and PRs for deadlock and cancellation found no existing report of this lock cycle; it is still present on main and no released fix was found.

Triaged by Codex (GPT-6 Astra).

Activity

  1. added
    bug
    on Oct 28, 2026
  2. stablebar-releases commented on Oct 29, 2026

    @stablebar-releases

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