googleapis / google-auth-library-swift

Auth client library for Swift command-line tools and cloud services. Supports OAuth1, OAuth2, and Google Application Default Credentials.
Apache License 2.0
134 stars 61 forks source link

Swift Compiler Crash on Swift Dev Trunk #36

Closed xanderdunn closed 3 years ago

xanderdunn commented 4 years ago

I haven't received any responses to tensorflow/swift#522, so I will see if this is relevant here. I don't know if this is a compiler bug or a library bug.

On Ubuntu 18.04, google-auth-library-swift successfully compiles with the Swift for Tensorflow v0.10 Toolchain, but it causes a build crash on the recently released v0.11 toolchain:

$ git clone https://github.com/googleapis/google-auth-library-swift
$ cd google-auth-library-swift
$ rm -rf .build/
$ which swift
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift
$ swift --version
Swift version 5.3-dev (LLVM db8896f3f345af2, Swift 61684f62a6132c0)
Target: x86_64-unknown-linux-gnu
$ swift build
Fetching https://github.com/apple/swift-nio.git
Fetching https://github.com/krzyzanowskim/CryptoSwift.git
Fetching https://github.com/attaswift/BigInt
Cloning https://github.com/krzyzanowskim/CryptoSwift.git
Resolving https://github.com/krzyzanowskim/CryptoSwift.git at 1.3.1
Cloning https://github.com/attaswift/BigInt
Resolving https://github.com/attaswift/BigInt at 5.1.0
Cloning https://github.com/apple/swift-nio.git
Resolving https://github.com/apple/swift-nio.git at 2.21.0
[1/30] Compiling CNIOSHA1 c_nio_sha1.c
[2/30] Compiling CNIOLinux shim.c
[3/30] Compiling CNIOLinux ifaddrs-android.c
[4/63] Compiling CNIOHTTPParser c_nio_http_parser.c
[5/63] Compiling CNIODarwin shim.c
swift-frontend: /swift-base/swift/lib/AST/GenericSignature.cpp:251: static swift::CanGenericSignature swift::CanGenericSignature::getCanonical(TypeArrayView<swift::GenericTypeParamType>, ArrayRef<swift::Requirement>, bool): Assertion `isCanonicalAnchor(secondType)' failed.
Stack dump:
0.  Program arguments: /home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend -frontend -c /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Addition.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/BigInt.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/BigUInt.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Bitwise Ops.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Codable.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Comparable.swift -primary-file /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Data Conversion.swift -primary-file /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Division.swift -primary-file /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Exponentiation.swift -primary-file /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Floating Point Conversion.swift -primary-file /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/GCD.swift -primary-file /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Hashable.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Integer Conversion.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Multiplication.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Prime Test.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Random.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Shifts.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Square Root.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Strideable.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/String Conversion.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Subtraction.swift /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Words and Bits.swift -supplementary-output-file-map /tmp/supplementaryOutputs-2b70e2 -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug -enable-testing -g -module-cache-path /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -parse-as-library -module-name BigInt -o /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion.swift.o -o /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Division.swift.o -o /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Exponentiation.swift.o -o /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Floating Point Conversion.swift.o -o /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/GCD.swift.o -o /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Hashable.swift.o -index-store-path /home/xander/dev/google-auth-library-swift/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules 
1.  Swift version 5.3-dev (LLVM db8896f3f345af2, Swift 61684f62a6132c0)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "/home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Division.swift")
3.  While type-checking extension of FixedWidthInteger (at /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Division.swift:11:1)
4.  While type-checking declaration 0x96aa840 (at /home/xander/dev/google-auth-library-swift/.build/checkouts/BigInt/Sources/Division.swift:12:13)
5.  While evaluating request PatternBindingEntryRequest((unknown decl), 0)
6.  While evaluating request PatternTypeRequest((pattern @ 0x96aa428))
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-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x5214dc4]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x52129be]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x521509c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7fe170bf18a0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fe16f493f47]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7fe16f4958b1]
/lib/x86_64-linux-gnu/libc.so.6(+0x3042a)[0x7fe16f48542a]
/lib/x86_64-linux-gnu/libc.so.6(+0x304a2)[0x7fe16f4854a2]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193f72e]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193e98d]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193e87c]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x193fb27]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x18805a5]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x1418ecf]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a2636]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13f4788]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a8cb7]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a87b6]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a1f61]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x13a1f34]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x1400212]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x137a793]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x137a4af]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x136cc71]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d180f]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d0871]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d3fab]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d0871]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x14d07a1]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142b995]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142cc70]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142c9a7]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142c8b1]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142b6de]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x142b6b4]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x63d3c9]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x63d296]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x4fd485]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x490dd8]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fe16f476b97]
/home/xander/swift-tensorflow-RELEASE-0.11-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift-frontend[0x49098a]
[6/127] Compiling BigInt Addition.swift
[7/127] Compiling CryptoSwift AEADChaCha20Poly1305.swift
[8/128] Merging module SwiftyBase64
[8/128] Compiling c-atomics.c
[8/128] Compiling c-nioatomics.c

I am not seeing this in a handful of other libraries I am successfully building.

xanderdunn commented 4 years ago

This is not specific to Swift for Tensorflow. This reproduces on Swift dev trunk Sept 28:

$ 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

This is caused by the BigInt dependency. See attaswift/BigInt#75. Filed a Swift bug report here

xanderdunn commented 3 years ago

Although the compiler crash has not yet been fixed in Swift, google-auth-library-swift now builds on latest Swift trunk and S4TF as a result of attaswift/BigInt#77 and the newly released BigInt 5.2.1.

timburks commented 3 years ago

Thanks for tracking this here!