Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7979] Circular Dependency in SwiftPM Causes Segfault #5354

Closed
swift-ci opened this issue Jun 12, 2018 · 4 comments
Closed

[SR-7979] Circular Dependency in SwiftPM Causes Segfault #5354

swift-ci opened this issue Jun 12, 2018 · 4 comments
Labels
bug good first issue Good for newcomers Edit

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-7979
Radar rdar://problem/41168213
Original Reporter dennisvennink (JIRA User)
Type Bug
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).

Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug, StarterBug
Assignee None
Priority Medium

md5: 27f03b630427f64c4428d1a3dfdf65f6

relates to:

  • SR-8380 Crash when a dependency depends on itself (cycle)

Issue 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
@ankitspd
Copy link
Member

@swift-ci create

@swift-ci
Copy link
Contributor Author

Comment by Erk Ekin (JIRA)

@aciidb0mb3r This looks like fixed in the version 5.2, and the output is

error: cyclic dependency declaration found: Foo -> Bar -> Foo

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
@tomerd tomerd added good first issue Good for newcomers Edit and removed Package Manager labels May 14, 2022
@azarovalex
Copy link

Cannot reproduce the crash in Swift 5.7 as well, cyclic dependency was correctly identified. The bug was fixed at some point as mentioned in the previous comment.

image

@tomerd please close the issue.

@neonichu
Copy link
Member

Thanks for testing this, @azarovalex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good for newcomers Edit
Projects
None yet
Development

No branches or pull requests

5 participants