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

Segmentation fault when building with coverage enabled

    XMLWordPrintable

    Details

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

      Xcode 11.4, Swift 5.2

      Description

      I found a segmentation fault when migrating our codebase to Swift 5.2 and Xcode 11.4. I managed to reproduce it in a very simple case:

      import UIKit
      
      @UIApplicationMain
      class AppDelegate: UIResponder, UIApplicationDelegate { }
      
      class EffectHandler {
          init(dispatchDelay: DispatchTimeInterval = .seconds(UIAccessibility.isVoiceOverRunning ? 4 : 2)) { }
      }
      

      Compiling the attached Xcode project with code coverage enabled using

      xcodebuild build-for-testing -project Segfault.xcodeproj -scheme Segfault -destination generic/platform\=iOS\ Simulator -configuration Debug -enableCodeCoverage YES

      triggers the following segmentation fault:

      1. Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)1. Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)2. While silgen constructor initializer SIL function "@$s8Segfault13EffectHandlerC13dispatchDelayAC8Dispatch0F12TimeIntervalO_tcfc"for 'init(dispatchDelay:)' (at /Users/patrickb/Desktop/Segfault/Segfault/AppDelegate.swift:7:5)0  swift                    0x000000010584e4ea PrintStackTraceSignalHandler(void*) + 421  swift                    0x000000010584dcc0 SignalHandler(int) + 3522  libsystem_platform.dylib 0x00007fff7164b42d _sigtramp + 293  libsystem_platform.dylib 0x00007fcb622e3828 _sigtramp + 40397383924  swift                    0x0000000102578510 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 1925  swift                    0x000000010257c1e3 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 2116  swift                    0x000000010257af87 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::ParameterList*) + 3277  swift                    0x000000010257e0e7 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 4878  swift                    0x000000010257ae03 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 2759  swift                    0x0000000101f72538 swift::SILProfiler::create(swift::SILModule&, swift::ForDefinition_t, swift::ASTNode, swift::SILDeclRef) + 282410 swift                    0x00000001019b619a swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 354611 swift                    0x0000000101aaf3b1 swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 14512 swift                    0x0000000101aad45b (anonymous namespace)::SILGenType::emitType() + 93913 swift                    0x00000001019bf5e2 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 8214 swift                    0x00000001019be7ac swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 135615 swift                    0x00000001019c082e swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 143816 swift                    0x00000001015a0657 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4805517 swift                    0x00000001015184d3 main + 128318 libdyld.dylib            0x00007fff714527fd start + 1error: Segmentation fault: 11 (in target 'Segfault' from project 'Segfault')

      Building without code coverage enabled fixes the issue:

      xcodebuild build-for-testing -project Segfault.xcodeproj -scheme Segfault -destination generic/platform\=iOS\ Simulator -configuration Debug
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            BalestraPatrick Patrick Balestra
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: