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

Compiler crash when using protocol function as member of protocol.

    XMLWordPrintable

    Details

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

      Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
      Target: x86_64-apple-darwin17.7.0

      Description

      Code to reproduce:

      protocol P {
        func f()
      }
      let f = P.f
      

      Stacktrace:

      0  swift                    0x000000010ac9964a PrintStackTraceSignalHandler(void*) + 42
      1  swift                    0x000000010ac98dfe SignalHandler(int) + 302
      2  libsystem_platform.dylib 0x00007fff504d9f5a _sigtramp + 26
      3  swift                    0x0000000107e0c0ed getSILFunctionType(swift::SILModule&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::AnyFunctionType::ExtInfo, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::ProtocolConformanceRef>) + 3709
      4  swift                    0x00000001078f7109 swift::Lowering::SILGenFunction::manageOpaqueValue(swift::Lowering::SILGenFunction::OpaqueValueState&, swift::SILLocation, swift::Lowering::SGFContext) + 169
      5  swift                    0x000000010790bb12 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 10002
      6  swift                    0x000000010790a641 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 4673
      7  swift                    0x000000010790a351 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 3921
      8  swift                    0x000000010791e719 void llvm::function_ref<void (swift::Expr*)>::callback_fn<swift::Lowering::RValue swift::Lowering::SILGenFunction::emitOpenExistentialExpr<swift::Lowering::RValue, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_16>(swift::OpenExistentialExpr*, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_16)::'lambda'(swift::Expr*)>(long, swift::Expr*) + 41
      9  swift                    0x000000010791eb7c swift::Lowering::SILGenFunction::emitOpenExistentialExprImpl(swift::OpenExistentialExpr*, llvm::function_ref<void (swift::Expr*)>) + 1004
      10 swift                    0x000000010790b187 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 7559
      11 swift                    0x0000000107909207 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optional<swift::SILLocation>) + 135
      12 swift                    0x00000001078fc393 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 227
      13 swift                    0x00000001078a3a8d swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 141
      14 swift                    0x00000001078a615f swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 431
      15 swift                    0x00000001078a501b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 939
      16 swift                    0x00000001078a6bd5 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 1333
      17 swift                    0x0000000106f283fe performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 28990
      18 swift                    0x0000000106f1ddc5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
      19 swift                    0x0000000106ec3a35 main + 1349
      20 libdyld.dylib            0x00007fff501cb015 start + 1
      21 libdyld.dylib            0x0000000000000042 start + 2950909998
      

      I don't know, is it valid code in swift or not, but I hope it will be at some point Nevertheless, I don't think that compiler crash is expected behaviour.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              zienag Alfred Zien
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: