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

Optional var in protocol implemented as lazy produces Seg fault 11

    XMLWordPrintable

    Details

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

      Version 8.0 beta (8S128d)
      Swift 3.0

      Description

      When a protocol declares an optional variable, and an implementer implements that variable as a lazy initialised one, the compiler will produce a Segmentation Fault 11. Changing the declaration to a non-lazy declaration will not fail to build

      A demo playground is attached, this produces the problem in an implementation on UIApplicationDelegate, and a complete protocol/implementation pair.

      Here is a log from another project which produces the same error.

      CompileSwift normal x86_64 /ios/whatson/whatson/WhatsOnAppDelegate.swift
          cd /ios/whatson
          /Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /ios/whatson/whatson/WhatsOnViewController.swift /ios/whatson/whatson/EventDetailsViewController.swift /ios/whatson/NSDate+Time.swift /ios/whatson/whatson/RoundedRectBorderView.swift /ios/whatson/whatson/UIView+Constraints.swift /ios/whatson/whatson/WhatsOnPresenter.swift /ios/whatson/whatson/UIColor+WhatsOn.swift -primary-file /ios/whatson/whatson/WhatsOnAppDelegate.swift /ios/whatson/whatson/CalendarSourceViewCell.swift /ios/whatson/whatson/NSDateCalculator.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Products/Debug-iphonesimulator -F /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Products/Debug-iphonesimulator -enable-testing -g -import-objc-header /ios/whatson/whatson-Bridging-Header.h -module-cache-path /Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/swift-overrides.hmap -Xcc -iquote -Xcc "/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-generated-files.hmap" -Xcc "-I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-own-target-headers.hmap" -Xcc "-I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-all-non-framework-target-headers.hmap" -Xcc -ivfsoverlay -Xcc /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/all-product-headers.yaml -Xcc -iquote -Xcc "/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-project-headers.hmap" -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Products/Debug-iphonesimulator/include -Xcc -I/Projects/j2objc/include -Xcc -Iuk/co/amlcurran/social -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/DerivedSources/x86_64 -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/ios/whatson -emit-module-doc-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate~partial.swiftdoc -Onone -module-name What_s_On -emit-module-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate~partial.swiftmodule -serialize-diagnostics-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.dia -emit-dependencies-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.d -emit-reference-dependencies-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.swiftdeps -o /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.o
      
      0  swift                    0x0000000104f5b34b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
      1  swift                    0x0000000104f5a636 llvm::sys::RunSignalHandlers() + 70
      2  swift                    0x0000000104f5b99f SignalHandler(int) + 287
      3  libsystem_platform.dylib 0x00007fff890b752a _sigtramp + 26
      4  libsystem_platform.dylib 000000000000000000 _sigtramp + 1995737840
      5  swift                    0x0000000102ea0c3f swift::Lowering::TypeConverter::makeConstantInterfaceType(swift::SILDeclRef) + 911
      6  swift                    0x0000000102e4dc2c swift::Lowering::TypeConverter::getConstantInfo(swift::SILDeclRef) + 156
      7  swift                    0x0000000102e4e566 swift::Lowering::TypeConverter::getConstantSelfParameter(swift::SILDeclRef) + 38
      8  swift                    0x0000000102ba1ede (anonymous namespace)::AccessorBasedComponent<swift::Lowering::PhysicalPathComponent>::getBaseAccessKind(swift::Lowering::SILGenFunction&, swift::AccessKind) const + 30
      9  swift                    0x0000000102ba0e38 drillToLastComponent(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::LValue&&, swift::Lowering::ManagedValue&, swift::AccessKind) + 120
      10 swift                    0x0000000102ba0c53 swift::Lowering::SILGenFunction::emitLoadOfLValue(swift::SILLocation, swift::Lowering::LValue&&, swift::Lowering::SGFContext, bool) + 227
      11 swift                    0x0000000102b860e6 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 5862
      12 swift                    0x0000000102b80656 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 22
      13 swift                    0x0000000102bcb185 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 837
      14 swift                    0x0000000102bc86f8 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 184
      15 swift                    0x0000000102bc9281 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 3137
      16 swift                    0x0000000102bc8635 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
      17 swift                    0x0000000102b94695 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 309
      18 swift                    0x0000000102b4bd16 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 198
      19 swift                    0x0000000102b446e2 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 610
      20 swift                    0x0000000102bcd595 (anonymous namespace)::SILGenType::emitType() + 1013
      21 swift                    0x0000000102bcd12e swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
      22 swift                    0x0000000102b491db swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 747
      23 swift                    0x0000000102b49e22 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 818
      24 swift                    0x0000000102b4a293 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 115
      25 swift                    0x0000000102a1b8bb performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 13131
      26 swift                    0x0000000102a17619 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2873
      27 swift                    0x00000001029e56c4 main + 2852
      28 libdyld.dylib            0x00007fff944a65ad start + 1
      29 libdyld.dylib            0x000000000000004d start + 1807063713
      Stack dump:
      0.	Program arguments: /Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /ios/whatson/whatson/WhatsOnViewController.swift /ios/whatson/whatson/EventDetailsViewController.swift /ios/whatson/NSDate+Time.swift /ios/whatson/whatson/RoundedRectBorderView.swift /ios/whatson/whatson/UIView+Constraints.swift /ios/whatson/whatson/WhatsOnPresenter.swift /ios/whatson/whatson/UIColor+WhatsOn.swift -primary-file /ios/whatson/whatson/WhatsOnAppDelegate.swift /ios/whatson/whatson/CalendarSourceViewCell.swift /ios/whatson/whatson/NSDateCalculator.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Downloads/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Products/Debug-iphonesimulator -F /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Products/Debug-iphonesimulator -enable-testing -g -import-objc-header /ios/whatson/whatson-Bridging-Header.h -module-cache-path /Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/swift-overrides.hmap -Xcc -iquote -Xcc /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-generated-files.hmap -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-own-target-headers.hmap -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/all-product-headers.yaml -Xcc -iquote -Xcc /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/What's On-project-headers.hmap -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Products/Debug-iphonesimulator/include -Xcc -I/Projects/j2objc/include -Xcc -Iuk/co/amlcurran/social -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/DerivedSources/x86_64 -Xcc -I/Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/ios/whatson -emit-module-doc-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate~partial.swiftdoc -Onone -module-name What_s_On -emit-module-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate~partial.swiftmodule -serialize-diagnostics-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.dia -emit-dependencies-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.d -emit-reference-dependencies-path /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.swiftdeps -o /Library/Developer/Xcode/DerivedData/whatson-dvipuqvjvndytvbknzqteckkjnpc/Build/Intermediates/whatson.build/Debug-iphonesimulator/whatson.build/Objects-normal/x86_64/WhatsOnAppDelegate.o 
      1.	While emitting SIL for getter for window at /ios/whatson/whatson/WhatsOnAppDelegate.swift:16:14
      

        Attachments

          Activity

            People

            Assignee:
            slavapestov Slava Pestov
            Reporter:
            amlcurran Alex Curran
            Votes:
            8 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: