Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-5932] Segmentation fault: 11 when creating a Set of optionals #48491

Closed
swift-ci opened this issue Sep 19, 2017 · 3 comments
Closed

[SR-5932] Segmentation fault: 11 when creating a Set of optionals #48491

swift-ci opened this issue Sep 19, 2017 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.0 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5932
Radar rdar://problem/34522739
Original Reporter tomquist (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
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)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.0Regression, CompilerCrash, TypeChecker
Assignee None
Priority Medium

md5: 28f9f1a700d5895f6e7a25d24b09a537

duplicates:

  • SR-5836 Compilation crash in Dictionary extension

is duplicated by:

  • SR-5934 Segmentation fault: 11 when creating a Set from an array of arrays
  • SR-6058 Segmentation fault: 11 when emitting SIL for custom collection function
  • SR-6256 Compiler crash with Dictionary(uniqueKeysWithValues:)

relates to:

  • SR-5934 Segmentation fault: 11 when creating a Set from an array of arrays

Issue 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.

@belkadan
Copy link
Contributor

cc @xedin, @rudkx

@rudkx
Copy link
Member

rudkx commented Sep 19, 2017

I hit a verification error, apply expression is not marked as throwing or non-throwing, which I believe we have a recent dup for somewhere, but if I comment that out I end up hitting another verification error about an expression having a null type, which really shouldn't happen after type checking is complete.

@rudkx
Copy link
Member

rudkx commented Sep 19, 2017

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 4.0 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants