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

Compiler crashes when using statement labels while code coverage is enabled

    XMLWordPrintable

    Details

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

      OS X 10.11.6 Beta 1
      Xcode 7.3.1 with Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
      Xcode 8 Beta 1 with Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)

      Description

      In Xcode, when compiling a unit testing target that has “Gather coverage data” enabled (Edit Scheme > Test > Info), the Swift 2.2 and 3.0 compiler crash when the compiled code contains statement labels that are actually used.

      A minimal test is a file with the following contents (“test.swift”):

      func foo() {
          testLabel: do {
              break testLabel
          }
      }
      

      Compile it with the following command to get the same crash as in Xcode:

      swiftc -enable-testing -profile-generate -profile-coverage-mapping test.swift

      Here’s the complete output of that command:

      0  swift                    0x000000010d37e34b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
      1  swift                    0x000000010d37d636 llvm::sys::RunSignalHandlers() + 70
      2  swift                    0x000000010d37e99f SignalHandler(int) + 287
      3  libsystem_platform.dylib 0x00007fff916be52a _sigtramp + 26
      4  libsystem_platform.dylib 0x00007fff54df9f00 _sigtramp + 3279141360
      5  swift                    0x000000010b58e91f swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 351
      6  swift                    0x000000010b58ec93 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 1235
      7  swift                    0x000000010b58e8f5 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 309
      8  swift                    0x000000010b5908a5 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 1045
      9  swift                    0x000000010b58c07e (anonymous namespace)::Traversal::doIt(swift::Decl*) + 254
      10 swift                    0x000000010b58bf6b swift::Decl::walk(swift::ASTWalker&) + 27
      11 swift                    0x000000010afe4869 walkForProfiling(swift::AbstractFunctionDecl*, swift::ASTWalker&) + 25
      12 swift                    0x000000010afe43c9 swift::Lowering::SILGenProfiling::assignRegionCounters(swift::AbstractFunctionDecl*) + 553
      13 swift                    0x000000010af6ca69 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 249
      14 swift                    0x000000010af6c1db swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 747
      15 swift                    0x000000010af6ce22 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 818
      16 swift                    0x000000010af6d293 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 115
      17 swift                    0x000000010ae3e8bb performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 13131
      18 swift                    0x000000010ae3a619 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2873
      19 swift                    0x000000010ae086c4 main + 2852
      20 libdyld.dylib            0x00007fff8e5435ad start + 1
      Stack dump:
      0.	Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -enable-testing -profile-generate -profile-coverage-mapping -color-diagnostics -module-name test -o /var/folders/w0/g3nlt5f14w9cy_shkddr9l800000gn/T/test-0d29ed.o 
      <unknown>:0: error: unable to execute command: Segmentation fault: 11
      <unknown>:0: error: compile command failed due to signal (use -v to see invocation)
      

        Attachments

          Activity

            People

            Assignee:
            vedantk Vedant Kumar
            Reporter:
            marco.masser Marco Masser
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: