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-9707] Swift 5 compiler crash #52145

Closed
groue opened this issue Jan 19, 2019 · 3 comments
Closed

[SR-9707] Swift 5 compiler crash #52145

groue opened this issue Jan 19, 2019 · 3 comments
Assignees
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 5.0

Comments

@groue
Copy link

groue commented Jan 19, 2019

Previous ID SR-9707
Radar rdar://problem/47470420
Original Reporter @groue
Type Bug
Status Resolved
Resolution Done
Environment

Swift 5, macOS X, org.swift.5020190118a snapshot

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug, 5.0Regression, CompilerCrash
Assignee @rjmccall
Priority Medium

md5: b4464f553b03693af154b9d7cf0d1774

Issue Description:

The following code has the Swift 5 compiler crash (snapshot org.swift.5020190118a):

protocol MutableFoo {
    mutating func foo()
    mutating func didFoo()
}

extension MutableFoo {
    mutating func foo() {
        performFoo()
    }
    
    mutating func performFoo() {
        didFoo()
    }
}

protocol Foo: MutableFoo {
    func foo()
    func didFoo()
}

extension Foo {
    func foo() {
        performFoo()
    }
    
    func performFoo() {
        didFoo()
    }
}
Assertion failed: (arg.hasLValueType() == param.isIndirectInOut()), function emit, file /Users/buildnode/jenkins/workspace/oss-swift-5.0-package-osx/swift/lib/SILGen/SILGenApply.cpp, line 2812.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-5.0-DEVELOPMENT-SNAPSHOT-2019-01-18-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/groue/Documents/git/groue/Swift5Crasher/Sources/Swift5Crasher/Swift5Crasher.swift -emit-module-path /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug/Swift5Crasher.build/Swift5Crasher~partial.swiftmodule -emit-module-doc-path /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug/Swift5Crasher.build/Swift5Crasher~partial.swiftdoc -emit-dependencies-path /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug/Swift5Crasher.build/Swift5Crasher.d -emit-reference-dependencies-path /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug/Swift5Crasher.build/Swift5Crasher.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -parse-as-library -module-name Swift5Crasher -o /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug/Swift5Crasher.build/Swift5Crasher.swift.o -index-store-path /Users/groue/Documents/git/groue/Swift5Crasher/.build/x86_64-apple-macosx/debug/index/store -index-system-modules 
1.  While emitting SIL for 'performFoo()' (at /Users/groue/Documents/git/groue/Swift5Crasher/Sources/Swift5Crasher/Swift5Crasher.swift:26:5)
2.  While silgen emitFunction SIL function "@$s13Swift5Crasher3FooPAAE07performC0yyF".
 for 'performFoo()' (at /Users/groue/Documents/git/groue/Swift5Crasher/Sources/Swift5Crasher/Swift5Crasher.swift:26:5)
0  swift                    0x000000010f397808 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010f396a85 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010f397e12 SignalHandler(int) + 258
3  libsystem_platform.dylib 0x00007fff62effb3d _sigtramp + 29
4  swift                    0x00000001106afda0 cmark_strbuf__initbuf + 136003
5  libsystem_c.dylib        0x00007fff62dbd1c9 abort + 127
6  libsystem_c.dylib        0x00007fff62d85868 basename_r + 0
7  swift                    0x000000010c047886 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 4614
8  swift                    0x000000010c053030 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus) && + 976
9  swift                    0x000000010c05277c (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapper<swift::FunctionType>&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&, swift::CanTypeWrapper<swift::FunctionType>&) + 1772
10 swift                    0x000000010c037496 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 3094
ntext) + 2016
12 swift                    0x000000010c0a07c0 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 80
13 swift                    0x000000010c09594e swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 1198
14 swift                    0x000000010c104e0c swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 8668
15 swift                    0x000000010c102c25 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
16 swift                    0x000000010c0b892a swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 426
17 swift                    0x000000010c02ebbd swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 237
18 swift                    0x000000010c026322 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 642
19 swift                    0x000000010c110aae swift::ASTVisitor<SILGenExtension, void, void, void, void, void, void>::visit(swift::Decl*) + 110
20 swift                    0x000000010c10de9b SILGenExtension::emitExtension(swift::ExtensionDecl*) + 59
21 swift                    0x000000010c10de55 swift::Lowering::SILGenModule::visitExtensionDecl(swift::ExtensionDecl*) + 21
22 swift                    0x000000010c02b896 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 822
23 swift                    0x000000010c02c7a6 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 294
24 swift                    0x000000010c02cd3c swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&) + 44
25 swift                    0x000000010b7b1353 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 7491
26 swift                    0x000000010b7ae57d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
27 swift                    0x000000010b76049e main + 686
28 libdyld.dylib            0x00007fff62d14ed9 start + 1
29 libdyld.dylib            0x000000000000002a start + 2637082962
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

This code does not crash the Swift 4 compiler.

It is the minimal code I could setup which prevents the GRDB library of the compatibility suite from successfully compile with Swift 5.

To reproduce, download https://github.com/groue/Swift5Crasher, and run the following command:

xcrun --toolchain org.swift.5020190118a swift build
@groue
Copy link
Author

groue commented Jan 25, 2019

The bug is also present in Xcode 10.2 beta 1.

Github issue: groue/GRDB.swift#472

@rjmccall
Copy link
Member

Reduction:

protocol MutableFoo {
    mutating func foo()
}

protocol Foo: MutableFoo {
    func foo()
}

extension Foo {
    func performFoo() {
        foo()
    }
}

@rjmccall
Copy link
Member

#22238

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

No branches or pull requests

3 participants