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

Segmentation Fault when compiling instance method call from protocol

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      > swift --version
      Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
      Target: x86_64-apple-darwin19.4.0

      Description

      I'm getting a segmentation fault when I try to compile code that includes an instance call using protocol methods (not sure how to properly word this). Consider this example:
      {{
      import Foundation

      protocol SomeProtocol

      { func someMethod() }

      class SomeClass: SomeProtocol {
      func someMethod()

      { print("hello") }

      }

      let a = SomeClass()
      SomeProtocol.someMethod(a)()
      }}

      Compiling this results in a segfault:

      ```
      0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret test.swift -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name test
      1. Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
      0 swift 0x000000010f6e54ea PrintStackTraceSignalHandler(void*) + 42
      1 swift 0x000000010f6e4cc0 SignalHandler(int) + 352
      2 libsystem_platform.dylib 0x00007fff6ba155fd _sigtramp + 29
      3 libsystem_platform.dylib 0x0000000000800000 _sigtramp + 2497620512
      4 swift 0x000000010b8cea8a swift::Lowering::SILGenFunction::emitOpenExistentialExprImpl(swift::OpenExistentialExpr*, llvm::function_ref<void (swift::Expr*)>) + 666
      5 swift 0x000000010b8bfc2a swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 38938
      6 swift 0x000000010b86df63 (anonymous namespace)::SILGenApply::visitExpr(swift::Expr*) + 51
      7 swift 0x000000010b863304 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 196
      8 swift 0x000000010b8d0297 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 823
      9 swift 0x000000010b856a5b swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 1227
      10 swift 0x000000010b8557ac swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 1356
      11 swift 0x000000010b85788a swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 1530
      12 swift 0x000000010b4393cb swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 55595
      13 swift 0x000000010b3af4d3 main + 1283
      14 libdyld.dylib 0x00007fff6b81ccc9 start + 1
      15 libdyld.dylib 0x000000000000000b start + 2491298627
      [1] 13168 segmentation fault swift test.swift
      ```

        Attachments

        1. compile.log.txt
          2 kB
        2. test.swift
          0.2 kB

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ben-z Ben Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: