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-8735] Swift Package Manager Error - Illegal Instruction: 4 #4893

Closed
swift-ci opened this issue Sep 13, 2018 · 7 comments
Closed

[SR-8735] Swift Package Manager Error - Illegal Instruction: 4 #4893

swift-ci opened this issue Sep 13, 2018 · 7 comments
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-8735
Radar None
Original Reporter Nasamura (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 0842e2da00764c3483315336388fb8e0

Issue Description:

Running

swift package update 

Last log before receiving the error:

sandbox-exec -p '(version 1)
(deny default)
(import "system.sb")
(allow file-read*)
(allow process*)
(allow sysctl*)
(allow file-write*
    (regex #"^/private/var/tmp/org\.llvm\.clang.*")
    (regex #"^/var/folders/t1/ql5g8dkd2rd5g6yf85fkrm3r0000gn/T/org\.llvm\.clang.*")
    (regex #"^/private/var/folders/t1/ql5g8dkd2rd5g6yf85fkrm3r0000gn/T/org\.llvm\.clang.*")
    (regex #"^/private/var/folders/t1/ql5g8dkd2rd5g6yf85fkrm3r0000gn/C/org\.llvm\.clang.*")
)
' /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -L /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk /var/folders/t1/ql5g8dkd2rd5g6yf85fkrm3r0000gn/T/TemporaryFile.MgFBKH.swift -fileno 6
Illegal instruction: 4
$ swift package --version
Apple Swift Package Manager - Swift 4.2.0 (swiftpm-14248)

On the latest MacOS Mojave beta.

@swift-ci
Copy link
Contributor Author

Comment by Nasamura (JIRA)

Strange thing I noticed about this bug is that it does not occur every time. I would estimate 9/10 runs of 'swift package update". My workaround at the moment is to keep running until it works...not ideal 🙂 Which must mean that the bug is not deterministic which is pretty odd, any idea why that would be?

Looks quite similar to https://bugs.swift.org/browse/SR-5595. Was this ever fixed?

@swift-ci
Copy link
Contributor Author

Comment by Nasamura (JIRA)

Also I'm fairly sure I haven't duplicated a dependency, at least within the same Package.swift file.

@swift-ci
Copy link
Contributor Author

Comment by Nasamura (JIRA)

Manually swiftc'd the Package.swift it appears to be failing on. Works fine.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk Package.swift -fileno 1

{"errors": [], "package": {"cLanguageStandard": null, "cxxLanguageStandard": null, "dependencies": [{"requirement": {"lowerBound": "3.0.0", "type": "range", "upperBound": "4.0.0"}, "url": "https://github.com/vapor/core.git"}, {"requirement": {"lowerBound": "3.0.0", "type": "range", "upperBound": "4.0.0"}, "url": "https://github.com/vapor/crypto.git"}, {"requirement": {"lowerBound": "1.2.0", "type": "range", "upperBound": "2.0.0"}, "url": "https://github.com/vapor/database-kit.git"}, {"requirement": {"lowerBound": "1.0.0", "type": "range", "upperBound": "2.0.0"}, "url": "https://github.com/vapor/service.git"}, {"requirement": {"lowerBound": "1.0.0", "type": "range", "upperBound": "2.0.0"}, "url": "https://github.com/apple/swift-nio.git"}, {"requirement": {"lowerBound": "2.0.2", "type": "range", "upperBound": "3.0.0"}, "url": "https://github.com/vapor/sql.git"}\], "name": "PostgreSQL", "products": [{"name": "PostgreSQL", "product_type": "library", "targets": ["PostgreSQL"], "type": null}], "targets": [{"dependencies": [{"name": "Async", "type": "byname"}, {"name": "Bits", "type": "byname"}, {"name": "Core", "type": "byname"}, {"name": "Crypto", "type": "byname"}, {"name": "DatabaseKit", "type": "byname"}, {"name": "NIO", "type": "byname"}, {"name": "Service", "type": "byname"}, {"name": "SQL", "type": "byname"}], "exclude": [], "name": "PostgreSQL", "path": null, "publicHeadersPath": null, "sources": null, "type": "regular"}, {"dependencies": [{"name": "Core", "type": "byname"}, {"name": "PostgreSQL", "type": "byname"}, {"name": "SQLBenchmark", "type": "byname"}], "exclude": [], "name": "PostgreSQLTests", "path": null, "publicHeadersPath": null, "sources": null, "type": "test"}]}}

@ankitspd
Copy link
Member

This is probably due to the non-determinism issue that was surfaced recently. It was fixed in #1759 Do you have any branch or revision based dependencies?

@swift-ci
Copy link
Contributor Author

Comment by Nasamura (JIRA)

There is one repo that I need the "master" branch on that another dependancy has a versioned dependancy of the same repo. .i.e.

.package(url: "https://github.com/vapor/crypto.git", .branch("master")), // in my repo

and

.package(url: "https://github.com/vapor/crypto.git", from: "3.0.0"), // in a dependancy

So that bug could be very well related.

Separately, the error reporting here could obviously be a lot more descriptive. Do you know what is causing the Illegal Instruction: 4 and where it could be caught/handled better?

@ankitspd
Copy link
Member

Yep, that case will triggering the crash. Note that there is no error in your package. This is a runtime crash due to a bug in SwiftPM code. The bug is fixed on trunk but was unfortunately shipped with the latest release of SwiftPM. This is mentioned in the Xcode 10's GM release notes:


The package manager might crash if a package graph contains shared dependencies with versioned and revision based requirements. Consider the following example package graph:
Root package:
PackageA@master
PackageA:
PackageB@master
PackageC@master
PackageB:
PackageC@1.0.0..<2.0.0

According to the package manager’s dependency resolution rules, this should resolve to: PackageA @ master, PackageB @ master and PackageC @ master. However, since the shared dependency PackageC is referenced with 1.0.0..<2.0.0 requirement, it may result in a crash.

Workaround: Use either versioned or revisioned based requirement for the shared package dependencies.


@swift-ci
Copy link
Contributor Author

Comment by Nasamura (JIRA)

Thanks, unfortunately I can't fix this without forking the repo (currently at least) as the code I need exists in an unversioned commit. I guess I'll have to do that.

Out of curiosity I'm still not understanding how exactly an unordered dictionary could cause a runtime crash?

@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
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants