Skip to content

swift-package hangs sometimes when resolving dependencies #9274

@bc-lee

Description

@bc-lee

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

Originally posted as FB16529896, but I received no response for 6 months, so I’m reposting it here.

Sometimes, in my project, the swift-package resolve command never finishes — it hangs indefinitely.

Specifically, running:

$ /opt/homebrew/bin/pstree | grep -C 3 swift-package
  |   |       \-+- 30015 redacted /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-package --package-path /path/to/project resolve
  |   |         |--= 33047 redacted <defunct>
  |   |         |--= 33059 redacted <defunct>
  |   |         \--= 33062 redacted <defunct>

shows that swift-package has spawned child processes that are now defunct.
These processes have already terminated, but the parent (swift-package) does not appear to reap them, and seems to be waiting indefinitely.

There are no relevant crash reports in Console.app, and attaching lldb to the hanging process did not succeed—likely due to macOS protections (such as SIP).

This issue happens intermittently in a large commercial project with multiple internal dependencies, so I unfortunately cannot provide a minimal reproducible example.

It would be great if you could help identify the cause of the hang, or provide diagnostic steps that could help collect useful traces the next time it happens.

Expected behavior

swift-package resolve should complete successfully or fail with a diagnostic message (e.g. network timeout, dependency resolution error), but it should not hang indefinitely.

Actual behavior

swift-package resolve sometimes never completes.
The process remains active, with several <defunct> child processes visible in pstree, suggesting a possible zombie process reaping issue or deadlock in process management.

Steps to reproduce

  1. Run swift-package resolve in a large project with multiple internal and remote dependencies.
  2. Wait for dependency resolution to start.
  3. Occasionally, the process will hang indefinitely with defunct child processes.
  4. Use pstree or ps to confirm the lingering subprocesses.

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

$ swift --version
swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx15.0
$ sw_vers -productVersion
15.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions