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

Segmentation fault: 11 when creating a Set of optionals

    XMLWordPrintable

    Details

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

      Apple Swift version 4.0 (swiftlang-900.0.65 clang-900.0.37)
      Target: x86_64-apple-macosx10.9
      Xcode Version 9.0 (9A235)

      Description

      This code snippet

      Set([""] as [String?])
      

      produces the following crash:

      0  swift                    0x000000010ad2ddba PrintStackTraceSignalHandler(void*) + 42
      1  swift                    0x000000010ad2d1f6 SignalHandler(int) + 662
      2  libsystem_platform.dylib 0x00007fffb8b70b3a _sigtramp + 26
      3  libsystem_platform.dylib 0x0000000000000012 _sigtramp + 1195963634
      4  swift                    0x0000000107f06e0b swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 427
      5  swift                    0x0000000107f05f6b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1115
      6  swift                    0x0000000107f078f9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 841
      7  swift                    0x00000001076a02c6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13014
      8  swift                    0x000000010769b784 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
      9  swift                    0x00000001076506a8 main + 12248
      10 libdyld.dylib            0x00007fffb8961235 start + 1
      11 libdyld.dylib            0x000000000000000f start + 1198124507
      Stack dump:
      0.	Program arguments: /Applications/Xcode9GM.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode9GM.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name test -o /var/folders/sg/7mgms6wn1zs529t4gqfljmh40000gp/T/test-a6db51.o 
      <unknown>:0: error: unable to execute command: Segmentation fault: 11
      <unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
      

      I don't know if this is the same issue, but here's another snippet, which produces a slightly different stacktrace:

      let a = Set([""].map { _ in nil as String? })
      

      Stacktrace:

      0  swift                    0x000000010e0b8dba PrintStackTraceSignalHandler(void*) + 42
      1  swift                    0x000000010e0b81f6 SignalHandler(int) + 662
      2  libsystem_platform.dylib 0x00007fffb8b70b3a _sigtramp + 26
      3  libsystem_platform.dylib 0x00000000000006ff _sigtramp + 1195965407
      4  swift                    0x000000010bc16c15 swift::NominalTypeDecl::hasFixedLayout() const + 21
      5  swift                    0x000000010b7aa931 (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::StructDecl*) + 49
      6  swift                    0x000000010b7a96c7 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type) + 2791
      7  swift                    0x000000010b317a36 swift::Lowering::SILGenModule::getSILGlobalVariable(swift::VarDecl*, swift::ForDefinition_t) + 1878
      8  swift                    0x000000010b2de060 swift::Lowering::SILGenFunction::emitInitializationForVarDecl(swift::VarDecl*) + 992
      9  swift                    0x000000010b2e0643 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 83
      10 swift                    0x000000010b291e8f swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 559
      11 swift                    0x000000010b290f6b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1115
      12 swift                    0x000000010b2928f9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 841
      13 swift                    0x000000010aa2b2c6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13014
      14 swift                    0x000000010aa26784 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
      15 swift                    0x000000010a9db6a8 main + 12248
      16 libdyld.dylib            0x00007fffb8961235 start + 1
      17 libdyld.dylib            0x000000000000000f start + 1198124507
      Stack dump:
      0.	Program arguments: /Applications/Xcode9GM.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode9GM.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name test -o /var/folders/sg/7mgms6wn1zs529t4gqfljmh40000gp/T/test-54d948.o 
      <unknown>:0: error: unable to execute command: Segmentation fault: 11
      <unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
      

      This crashes in both, Swift 4 and Swift 3 mode.

      In Swift 3.1 both examples error as expected.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tomquist Tom Quist
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: