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

Segfault on compiling test using an @objc protocol with name distinct from the Objective-C generated name

    XMLWordPrintable

    Details

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

      Description

      Given an Objective C method like:

      • (NSData *)transactionForTransactionData(_ data: NSData)

      ... the Swift Compiler would normally generate a Swift function like:

      func transaction(for transactionData: Data) -> Data

      But, if this Objective C method was auto-created by the Objective C compiler due to an Objective C class Bar's header declaring an implementing an @objc Swift protocol Fooy in another module Foo with a function name like:

      @objc func transactionForTransactionData(_ data: NSData) -> NSData

      ... without actually listing the implementation for it ...

      ... and if that Bar also inherits from FBSnapshotTestCase ...

      ... and if there is yet another module Qux in which another class Qux inherits from that Bar, and then if MocQux inherits from Qux, and declares its own local implementations of the Foo protocol methods...

      then we get Segmentation Fault 11.

      See sample project and README for instructions: https://github.com/1oo7/segfault11.git

      Stacktrace:

      1. Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
      2. While looking for 'myNavigationController'3. While ...in 'REDACTED' (in module 'REDACTED')
      4. /Users/REDACTED/Build/Products/Testing-iphonesimulator/REDACTED.framework/Headers/REDACTED-Swift.h:1375:76: importing 'MyProtocol::myNavigationController'
      0 swift 0x000000010e300865 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
      1 swift 0x000000010e2ff865 llvm::sys::RunSignalHandlers() + 85
      2 swift 0x000000010e300e1f SignalHandler(int) + 111
      3 libsystem_platform.dylib 0x00007fff704165fd _sigtramp + 29
      4 libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338632829472
      5 swift 0x000000010ae70003 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*) + 259
      6 swift 0x000000010ae588db swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, swift::importer::ImportNameVersion, bool, bool) + 1483
      7 swift 0x000000010ae42972 swift::ClangImporter::loadObjCMethods(swift::ClassDecl*, swift::ObjCSelector, bool, unsigned int, llvm::TinyPtrVector<swift::AbstractFunctionDecl*>&) + 258
      8 swift 0x000000010afad19d swift::ASTContext::loadObjCMethods(swift::ClassDecl*, swift::ObjCSelector, bool, unsigned int, llvm::TinyPtrVector<swift::AbstractFunctionDecl*>&) + 301
      9 swift 0x000000010b17f8e4 swift::ClassDecl::lookupDirect(swift::ObjCSelector, bool) + 180
      10 swift 0x000000010ad47a36 lookupObjCMethodInClass(swift::ClassDecl*, swift::ObjCSelector, bool, bool, swift::SourceManager&, bool) + 54
      11 swift 0x000000010ad47440 swift::diagnoseUnintendedObjCMethodOverrides(swift::SourceFile&) + 944
      12 swift 0x000000010ae290da swift::performWholeModuleTypeChecking(swift::SourceFile&) + 250
      13 swift 0x0000000109fa3abd swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 8237
      14 swift 0x0000000109e642fd swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6845
      15 swift 0x0000000109de8c07 main + 1255
      16 libdyld.dylib 0x00007fff7021dcc9 start + 1
      17 libdyld.dylib 0x0000000000000099 start + 18446603338634896337
      error: Segmentation fault: 11 (in target 'REDACTEDTests' from project 'REDACTED')

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            xy Jonathan Gilbert
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: