Uploaded image for project: 'Swift'
  1. Swift
  2. SR-7979

Circular Dependency in SwiftPM Causes Segfault

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Package Manager
    • Labels:
    • Environment:

      2,4 GHz Intel Core i7 MacBook Pro (17-inch, Late 2011) running macOS High Sierra 10.13.5 (17F77), Xcode 10.0 (10L176w) and Swift 4.2.0 (swiftpm-14228).

      Description

      We have two packages, `Foo` and `Bar`. Both are in the same directory:

      .
      ├─ Foo/
      │  ├─ Sources/
      │  │  └─ Foo/
      │  │     └─ Foo.swift
      │  ├─ Tests/
      │  │  └─ FooTests/
      │  │     └─ FooTests.swift
      │  └─ Package.swift
      └─ Bar/
         ├─ Sources/
         │  └─ Bar/
         │     └─ Bar.swift
         ├─ Tests/
         │  └─ BarTests/
         │     └─ BarTests.swift
         └─ Package.swift
      

      Both define two targets; a library and tests:

      // swift-tools-version:4.2
      import PackageDescription
      
      let package = Package(
        name: "Foo",
        products: [
          .library(name: "Foo", targets: ["Foo"])
        ],
        dependencies: [
          .package(url: "../Bar", .branch("master"))
        ],
        targets: [
          .target(name: "Foo", dependencies: []),
          .testTarget(name: "FooTests", dependencies: ["Bar"])
        ]
      )
      
      // swift-tools-version:4.2
      import PackageDescription
      
      let package = Package(
        name: "Bar",
        products: [
          .library(name: "Bar", targets: ["Bar"])
        ],
        dependencies: [
          .package(url: "../Foo", .branch("master"))
        ],
        targets: [
          .target(name: "Bar", dependencies: ["Foo"]),
          .testTarget(name: "BarTests", dependencies: ["Bar"])
        ]
      )
      

      Running `swift build`, `swift package` or any of its variants on either package will cause it to segfault:

      $ cd Foo
      $ swift build
      Updating /Absolute/Path/To/Bar
      [1] 10067 segmentation fault swift build
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              dennisvennink Dennis Vennink
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: