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

GSB produces signatures with non-canonical same-type constraints

    XMLWordPrintable

    Details

      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: 

      $ which swift
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift
      $ swift --version
      Swift version 5.3-dev (LLVM 19447e27024a8d4, Swift f89dbd325b96dd6)
      Target: x86_64-unknown-linux-gnu
      $ which swift
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-07-16-a-ubuntu18.04/usr/bin/swift
      $ swift --version
      Swift version 5.3-dev (LLVM a2e0564af78e841, Swift 1224d8b2d312c55)
      
      

       

      To reproduce:

      $ git clone https://github.com/attaswift/BigInt.git
      $ cd BigInt
      $ swift build
      

       

      The compiler crash:

      $ 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<swift::GenericTypeParamType>, ArrayR
      ef<swift::Requirement>, bool): Assertion `isCanonicalAnchor(secondType)' failed.
      Stack dump:
      0. Program arguments: /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-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/xande
      r/dev/BigInt/Sources/Division.swift -primary-file /home/xander/dev/BigInt/Sources/Exponentiation.swift -primary-file /home/xan
      der/dev/BigInt/Sources/Floating Point Conversion.swift -primary-file /home/xander/dev/BigInt/Sources/GCD.swift -primary-file /
      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/BigInt/Sources/Prime Test.swift /home/xander/dev/BigInt/Sources/Random.swift /h
      ome/xander/dev/BigInt/Sources/Shifts.swift /home/xander/dev/BigInt/Sources/Square Root.swift /home/xander/dev/BigInt/Sources/S
      trideable.swift /home/xander/dev/BigInt/Sources/String Conversion.swift /home/xander/dev/BigInt/Sources/Subtraction.swift /hom
      e/xander/dev/BigInt/Sources/Words and Bits.swift -supplementary-output-file-map /tmp/supplementaryOutputs-092919 -target x86_6
      4-unknown-linux-gnu -disable-objc-interop -I /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-versio$ 5 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-anonymous-context-mangled-names -parse-as-library -module-name BigInt -o /home/xa$der/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Data Conversion.swift.o -o /home/xander/dev/BigInt/.build/x$6_64-unknown-linux-gnu/debug/BigInt.build/Division.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/B$gInt.build/Exponentiation.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Floating Poin$ Conversion.swift.o -o /home/xander/dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/GCD.swift.o -o /home/xander$dev/BigInt/.build/x86_64-unknown-linux-gnu/debug/BigInt.build/Hashable.swift.o -index-store-path /home/xander/dev/BigInt/.bui$d/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
      1. Swift version 5.3-dev (LLVM 19447e27024a8d4, Swift f89dbd325b96dd6)
      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 0x9d032e8 (at /home/xander/dev/BigInt/Sources/Division.swift:12:13)
      5. While evaluating request PatternBindingEntryRequest((unknown decl), 0)
      6. While evaluating request PatternTypeRequest((pattern @ 0x9d02ec8))
      7. While canonicalizing generic signature <τ_0_0 where τ_0_0 : FixedWidthInteger, τ_0_0 == τ_0_0.Magnitude, τ_0_0.Magnit$de == τ_0_0.Magnitude.Magnitude.Magnitude> in requirement #2
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x5232124]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x522fd1e]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x52323fc]
      /lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7f633b07b8a0]
      /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f633991df47]
      /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f633991f8b1]
      /lib/x86_64-linux-gnu/libc.so.6(+0x3042a)[0x7f633990f42a]
      /lib/x86_64-linux-gnu/libc.so.6(+0x304a2)[0x7f633990f4a2]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x197ff7e]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x197f1dd]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x197f0cc]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1980377]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x18bfa25]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x145ef2f]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13e7846]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x143a308]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13edf67]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13eda66]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13e7171]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13e7144]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x14462c2]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13bf023]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13bed3f]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x13b1571]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1509f6f]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1508fb1]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x150c70b]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1508fb1]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1508ee1]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1472065]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1473270]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1472fa7]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1472eb1]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1471dae]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x1471d84]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x6467c9]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x646696]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x4fdd6c]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x491458]
      /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f6339900b97]
      /home/xander/swift-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift-frontend[0x49100a]
      
      

       

      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:

       

      $ which swift
      /home/xander/swift-tensorflow-RELEASE-0.10-cuda10.2-cudnn7-ubuntu18.04/usr/bin/swift
      $ swift --version
      Swift version 5.3-dev (LLVM 55d27a5828, Swift 6a5d84ec08)
      Target: x86_64-unknown-linux-gnu

       

       

      It also successfully complies on 5.3 release branch on Ubuntu 18.04:

      $ which swift
      /home/xander/swift-5.3-DEVELOPMENT-SNAPSHOT-2020-08-31-a-ubuntu18.04/usr/bin/swift
      $ swift --version
      Swift version 5.3-dev (LLVM 3fa9679add, Swift d24649a4d6)
      Target: x86_64-unknown-linux-gnu

       

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              slavapestov Slava Pestov
              Reporter:
              xanderai Xander Dunn
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated: