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-13491] GSB produces signatures with non-canonical same-type constraints #55933
Comments
@swift-ci create |
Comment by Xander Dunn (JIRA) This reproduces on latest Swift trunk: $ which swift
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-09-28-a-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM 8d6dfcd39f3bc7d, Swift 35d765f87cd2a30)
Target: x86_64-unknown-linux-gnu |
Comment by Xander Dunn (JIRA) This issue is still present on Swift dev trunk 2020-10-07: $ which swift
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift
(base) xander@plutus-3:~/dev/BigInt$ swift --version
Swift version 5.3-dev (LLVM 240312aa7333e90, Swift 15bf0478ad7c47c)
Target: x86_64-unknown-linux-gnu
$ swift build swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/swift/lib/AST/GenericSignature.cpp:251: static swift::CanGenericSignature swift::CanGenericSignature::getCanonical(TypeArrayView<sw$ft::GenericTypeParamType>, ArrayRef<swift::Requirement>, bool): Assertion `isCanonicalAnchor(secondType)' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Program arguments: /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend -frontend -c /home/xander/dev/BigInt/Sources/Addition.swift /home/xander/dev/BigInt/Sources/BigInt.swift /home/xander/dev/BigInt/Sources/BigUInt.swift /home/xander/dev/BigInt/Sources/Bitwise Ops.swift /home/xander/dev/BigInt/Sources/Codable.swift /home/xander/dev/BigInt/Sources/Comparable.swift -primary-file /home/xander/
dev/BigInt/Sources/Data Conversion.swift -primary-file /home/xander/dev/BigInt/Sources/Division.swift /home/xander/dev/BigInt/Sources/Exponentiation.swift /home/xander/dev/BigInt/Sources/Floating Point Conversion.swift
/home/xander/dev/BigInt/Sources/GCD.swift /home/xander/dev/BigInt/Sources/Hashable.swift /home/xander/dev/BigInt/Sources/Integer Conversion.swift /home/xander/dev/BigInt/Sources/Multiplication.swift /home/xander/dev/Big
Int/Sources/Prime Test.swift /home/xander/dev/BigInt/Sources/Random.swift /home/xander/dev/BigInt/Sources/Shifts.swift /home/xander/dev/BigInt/Sources/Square Root.swift /home/xander/dev/BigInt/Sources/Strideable.swift $
home/xander/dev/BigInt/Sources/String Conversion.swift /home/xander/dev/BigInt/Sources/Subtraction.swift /home/xander/dev/BigInt/Sources/Words and Bits.swift -emit-module-path /home/xander/dev/BigInt/.build/x86_64-unkn$
wn-linux-gnu/debug/BigInt.build/Data Conversion~partial.swiftmodule -emit-module-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Division~partial.swiftmodule -emit-module-doc-path /home/$
ander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion~partial.swiftdoc -emit-module-doc-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Division~partial.swi$
tdoc -emit-module-source-info-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion~partial.swiftsourceinfo -emit-module-source-info-path /home/xander/dev/BigInt/.build/x86_64-$
nknown-linux-gnu/debug/BigInt.build/Division~partial.swiftsourceinfo -emit-dependencies-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion.d -emit-dependencies-path /home/xa$
der/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Division.d -emit-reference-dependencies-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion.swiftdeps -emit-$
eference-dependencies-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Division.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/xander/dev/BigInt/.build/x86_64-u$
known-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymo$
s-context-mangled-names -parse-as-library -module-name BigInt -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux$
gnu/debug/BigInt.build/Division.swift.o -index-store-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
1. Swift version 5.3-dev (LLVM 240312aa7333e90, Swift 15bf0478ad7c47c)
2. While evaluating request TypeCheckSourceFileRequest(source_file "/home/xander/dev/BigInt/Sources/Division.swift")
3. While type-checking extension of FixedWidthInteger (at /home/xander/dev/BigInt/Sources/Division.swift:11:1)
4. While type-checking declaration 0xa299e90 (at /home/xander/dev/BigInt/Sources/Division.swift:12:13)
5. While evaluating request PatternBindingEntryRequest((unknown decl), 0)
6. While evaluating request PatternTypeRequest((pattern @ 0xa299a70))
7. While canonicalizing generic signature <τ_0_0 where τ_0_0 : FixedWidthInteger, τ_0_0 == τ_0_0.Magnitude, τ_0_0.Magnitude == τ_0_0.Magnitude.Magnitude.Magnitude> in requirement #​2
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x5663ef4]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x566198e]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x56640dc]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7fe0295e08a0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fe027e82f47]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7fe027e848b1]
/lib/x86_64-linux-gnu/libc.so.6(+0x3042a)[0x7fe027e7442a]
/lib/x86_64-linux-gnu/libc.so.6(+0x304a2)[0x7fe027e744a2]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x19dc815]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x19dba6d]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x19db95c]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x19dcc37]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x1915c45]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x14cce7f]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x1457f96]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x14aa5b8]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x145e057]
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-07-a-ubuntu18.04/usr/bin/swift-frontend[0x145db56] |
Comment by Xander Dunn (JIRA) This issue is still present on Swift dev trunk 2020-10-15: $ which swift
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-15-a-ubuntu18.04/usr/bin/swift
(base) xander@plutus-3:~/dev/BigInt$ swift --version
Swift version 5.3-dev (LLVM 2ea629d94ab01c3, Swift aa3e5904f8ba8bf)
Target: x86_64-unknown-linux-gnu |
Comment by Xander Dunn (JIRA) This issue is still present on trunk 2020-10-24: $ which swift
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-10-24-a-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM 56a74d3b9591abe, Swift 246fe46aa77b582)
Target: x86_64-unknown-linux-gnu |
Comment by Xander Dunn (JIRA) This issue is still present on trunk 2020-11-05: $ which swift
/home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-11-05-a-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM ea8eac6ba760b92, Swift e8151ee2b27776f)
Target: x86_64-unknown-linux-gnu |
Yeah, I don't expect it to get fixed randomly along the way. The GSB needs some refactoring to address this and related issues with signature canonicalization. |
Comment by Xander Dunn (JIRA) Thanks @slavapestov! I don't know the causes of the issue so it appeared randomly for me and I didn't realize it had your attention. We are excited for the resolution so that we can use more recent versions of Swift for Tensorflow in our project. I know commitments can't be made, but generally speaking is this the sort of thing you would imagine on the order of months or a year+? If it's a longer time horizon we should break up our project into multiple processes that communicate via shared memory so that our Swift for Tensorflow code doesn't rely on BigInt. Thanks very much for working on it! |
Another option would be to change the BigInt library to avoid the problematic same-type constraint. I'm assuming your copy of BigInt.swift is identical to the one in test/Prototypes in the Swift repository. If so, it has a definition like this:
You'll need to remove the "where Word.Magnitude == Word" constraint and add a few forced casts now that the compiler no longer knows they're the same type. Here is the diff I used:
The test file compiles and runs for me now, but I haven't done any further testing. I hope this helps! |
Comment by Xander Dunn (JIRA) This was hugely helpful, thank you very much @slavapestov! I successfully made a workaround on the BigInt project. Diff is here. |
Environment
Ubuntu 18.04
Additional Detail from JIRA
md5: 81ed32786959c66c1898efb8b960df73
is duplicated by:
Issue Description:
Recent changes in the Swift toolchain have caused the BigInt project (https://github.com/attaswift/BigInt) to produce a Swift compiler crash when building on Ubuntu 18.04. It does not occur on macOS 10.15.6.
I tested on Swift Trunk snapshots from August 31st and July 16th:
To reproduce:
The compiler crash:
This regression is not related to any recent changes in the BigInt library. I reproduced the error on tags `master`, `v5.1.0`, `v5.2.0`, `v5.0.0`, and `v4.0.0`.
I wasn't able to find Trunk snapshots older than July 16th, but I am able to successfully compile this library with Swift for Tensorflow v0.10, which I believe is from June trunk:
It also successfully complies on 5.3 release branch on Ubuntu 18.04:
The regression appears specific to Trunk, and is preventing us from upgrading to Swift for Tensorflow v0.11 in our project because it breaks the build.
The text was updated successfully, but these errors were encountered: