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

fatal error when compiling big tuples

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Environment:

      Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9)
      Target: x86_64-apple-darwin19.0.0

      Description

      https://forums.swift.org/t/t-uple-max-size/30635

      When I try to compile a tuple with `2**20 + 1` elements, it crashes the compiler with "Type variable id overflow"

      To reproduce I use the following python3 program (number of elements is one bigger than the `size` variable):

      size = 2**20
      print("let x: Int = 0")
      print("let bigTuple: (", end = '')
      for i in range(size):
          print("Int,", end = '')
      print("Int) = (", end = '')
      for i in range(size):
          print("x,", end = '')
      print("x)")
      

      The full(ish) error message:

      <unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
      <unknown>:0: note: Type variable id overflow
      Stack dump:
      0.	Program arguments: /Users/myUsername/Desktop/Xcode/Xcode 11.2.1 GM.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file main.swift -target x86_64-apple-darwin19.0.0 -enable-objc-interop -sdk /Users/myUsername/Desktop/Xcode/Xcode 11.2.1 GM.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -module-name main -o /var/folders/9r/3t0y3zlj2l34w2t5vsgxz_7w0000gn/T/main-86f56f.o
      1.	While type-checking statement at [main.swift:2:1 - line:2:6291481] RangeText="let bigTuple: <snip>
      2.	While type-checking declaration 0x121596fb0 (at main.swift:2:1)
      3.	While type-checking expression at [main.swift:2:4194327 - line:2:6291481] RangeText="(x,x,x,x,x <snip>
      0  swift                    0x0000000114076a13 PrintStackTraceSignalHandler(void*) + 51
      1  swift                    0x00000001140761e6 SignalHandler(int) + 358
      2  libsystem_platform.dylib 0x00007fff71d4cb1d _sigtramp + 29
      3  libsystem_platform.dylib 0x000000011f3aa4a7 _sigtramp + 2909133223
      4  libsystem_c.dylib        0x00007fff71c22a08 abort + 120
      5  swift                    0x000000010fcb99e0 std::__1::unique_ptr<swift::DiagnosticConsumer, std::__1::default_delete<swift::DiagnosticConsumer> > llvm::function_ref<std::__1::unique_ptr<swift::DiagnosticConsumer, std::__1::default_delete<swift::DiagnosticConsumer> > (swift::InputFile const&)>::callback_fn<createSerializedDiagnosticConsumerIfNeeded(swift::FrontendInputsAndOutputs const&)::$_15>(long, swift::InputFile const&) + 0
      6  swift                    0x0000000113fef836 llvm::report_fatal_error(llvm::Twine const&, bool) + 278
      7  swift                    0x0000000113fef71b llvm::report_fatal_error(char const*, bool) + 43
      8  swift                    0x00000001106f5c5c swift::constraints::ConstraintSystem::createTypeVariable(swift::constraints::ConstraintLocator*, unsigned int) + 236
      9  swift                    0x00000001106b9034 swift::ASTVisitor<(anonymous namespace)::ConstraintGenerator, swift::Type, void, void, void, void, void>::visit(swift::Expr*) + 15268
      10 swift                    0x00000001106b44c0 (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 464
      11 swift                    0x0000000110b7e307 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 2871
      12 swift                    0x00000001106ae921 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*, swift::DeclContext*) + 849
      13 swift                    0x00000001106ffccb swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 8267
      14 swift                    0x0000000110803af1 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 1041
      15 swift                    0x0000000110805cf2 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 898
      16 swift                    0x0000000110806a71 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 225
      17 swift                    0x0000000110813a6a (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 7802
      18 swift                    0x00000001108b3b9e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 23854
      19 swift                    0x00000001108ade11 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 129
      20 swift                    0x00000001108b6b97 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 263
      21 swift                    0x00000001108d22b8 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1656
      22 swift                    0x000000010ffc4687 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 4679
      23 swift                    0x000000010fcba216 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 806
      24 swift                    0x000000010fcb66e4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
      25 swift                    0x000000010fc43be3 main + 1219
      26 libdyld.dylib            0x00007fff71b4b405 start + 1
      27 libdyld.dylib            0x000000000000000e start + 2387299338
      <unknown>:0: error: unable to execute command: Abort trap: 6
      <unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
      

        Attachments

          Activity

            People

            Assignee:
            cukier cukr
            Reporter:
            cukier cukr
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: