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

Compiler aborts due to segmentation fault with main.swift

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
    • Environment:

      macOS 10.12.4
      Xcode 8.3 and 8.3.1

      Description

      Problem

      Compiler fails when running unit tests with a Segmentation fault: 11.

      Such crash happens when both are true:

      • Code coverage is enabled (Gather coverage data option is enabled on the scheme)
      • A custom main.swift file is present to prevent loading the app delegate when running tests.

      To be clear, if one disables the code coverage, tests run just fine.

      main.swift

      // main.swift
      import UIKit
      
      let argc = CommandLine.argc
      let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self,
                                                                            capacity: Int(CommandLine.argc))
      let delegate = NSClassFromString("XCTestCase") == nil ? NSStringFromClass(AppDelegate.self) : nil
      UIApplicationMain(argc, argv, nil, delegate)
      

      How to reproduce

      1. Create a new empty project
      2. Enable code coverage
      3. Add main.swift with the code presented above
      4. Run unit tests

      The attached project was created following these steps.

      Stack Trace

      0  swift                    0x000000010a4a5ec7 PrintStackTraceSignalHandler(void*) + 39
      1  swift                    0x000000010a4a5376 SignalHandler(int) + 646
      2  libsystem_platform.dylib 0x00007fffbd0a6b3a _sigtramp + 26
      3  swift                    0x00000001082b1ddb swift::NewMangling::Mangler::addSubstitution(void const*) + 171
      4  swift                    0x00000001082da585 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 917
      5  swift                    0x00000001082dadea swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 378
      6  swift                    0x00000001082da67f (anonymous namespace)::Traversal::doIt(swift::Decl*) + 1167
      7  swift                    0x0000000107b57715 walkForProfiling(swift::Decl*, swift::ASTWalker&) + 629
      8  swift                    0x0000000107b5c222 swift::Lowering::ProfilerRAII::ProfilerRAII(swift::Lowering::SILGenModule&, swift::Decl*) + 1538
      9  swift                    0x0000000107ab1dcd swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 253
      10 swift                    0x0000000107ab101b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1483
      11 swift                    0x0000000107ab2bf9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
      12 swift                    0x00000001072c4da2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 42402
      13 swift                    0x000000010727457c main + 9052
      14 libdyld.dylib            0x00007fffbce97235 start + 1
      

        Attachments

          Activity

            People

            Assignee:
            slavapestov Slava Pestov
            Reporter:
            renato Renato Rodrigues
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: