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-7591] Compiler segfault 11: Cyclic declaration with a guard statement #50133

Closed
swift-ci opened this issue May 3, 2018 · 3 comments
Closed
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

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 3, 2018

Previous ID SR-7591
Radar rdar://problem/39978219
Original Reporter tdimeco (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)

Xcode 9.3 (9E145)

macOS 10.13.4 (17E202)

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

md5: 8fcced680f2c7d9d52f448773a617e4b

duplicates:

  • SR-7567 Crash lowering ill-scoped use of variable

relates to:

  • SR-7567 Crash lowering ill-scoped use of variable

Issue Description:

Hello,

There is Segmentation fault: 11 compiler crash while emitting SIL for a function containing a cyclic declaration between a guard statement and un let, for instance:

func foo() {
    guard let a = b else { return }
    let b = a
}

Here is the complete stack trace of the swift foo.swift command:

Thomas:~$ swift foo.swift 
0  swift                    0x000000010ad2affa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010ad2a3b6 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff77a1df5a _sigtramp + 26
3  libsystem_platform.dylib 0x000000000a12a81e _sigtramp + 2456864990
4  swift                    0x0000000108701aaf swift::NominalTypeDecl::hasFixedLayout(swift::ModuleDecl*, swift::ResilienceExpansion) const + 31
5  swift                    0x000000010822b3e1 (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::StructDecl*) + 49
6  swift                    0x0000000108229c2f swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type) + 3743
7  swift                    0x0000000107c9510d swift::Lowering::SILGenFunction::emitInitializationForVarDecl(swift::VarDecl*, bool) + 1773
8  swift                    0x0000000107c97768 swift::ASTVisitor<(anonymous namespace)::InitializationForPattern, void, void, void, std::__1::unique_ptr<swift::Lowering::Initialization, std::__1::default_delete<swift::Lowering::Initialization> >, void, void>::visit(swift::Pattern*) + 360
9  swift                    0x0000000107c99a8d swift::Lowering::SILGenFunction::emitStmtCondition(llvm::MutableArrayRef<swift::StmtConditionElement>, swift::Lowering::JumpDest, swift::SILLocation, swift::ProfileCounter, swift::ProfileCounter) + 845
10 swift                    0x0000000107d17634 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 15732
11 swift                    0x0000000107d15218 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 6488
12 swift                    0x0000000107cd16cb swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 379
13 swift                    0x0000000107c398c5 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 565
14 swift                    0x0000000107c38cb5 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 741
15 swift                    0x0000000107c41cdb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1371
16 swift                    0x0000000107c43b32 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 1490
17 swift                    0x000000010738845c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 27500
18 swift                    0x000000010737fe64 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
19 swift                    0x00000001073348b5 main + 18917
20 libdyld.dylib            0x00007fff7770f015 start + 1
21 libdyld.dylib            0x000000000000000a start + 2291077110
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret foo.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name foo 
1.  While emitting SIL for 'foo()' at foo.swift:1:1
2.  While silgen emitFunction SIL function "@_T03fooAAyyF".
 for 'foo()' at foo.swift:1:1
Segmentation fault: 11

Feel free to ask if you need more details.

Have a good day!

Thomas

@belkadan
Copy link
Contributor

belkadan commented May 4, 2018

Likely the same root cause as SR-7567, but maybe not.

@belkadan
Copy link
Contributor

belkadan commented May 4, 2018

@swift-ci create

@eeckstein
Copy link
Member

Already fixed on master.

@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
Projects
None yet
Development

No branches or pull requests

4 participants