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-1333] Crash after "warning: no calls to throwing functions occur within 'try' expression" #43941

Closed
nevil opened this issue Apr 27, 2016 · 9 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 4.0

Comments

@nevil
Copy link

nevil commented Apr 27, 2016

Previous ID SR-1333
Radar rdar://problem/33351098
Original Reporter @nevil
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Mac, Xcode 7.3 with Xcode Swift 2.2.1 Snapshot 2016-04-23 (a),
or swift-4.0-DEVELOPMENT-SNAPSHOT-2017-05-11

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

md5: 852695a5356393ba0414ab26aaa5f827

Issue Description:

swift crashes when it is compiling this simple, incorrect, snippet:

func returnTrue() -> Bool {
    return true
}

func crashFunction() {
    guard (try? returnTrue()) != nil else {
        return
    }
}

Stack trace

main.swift:6:17: warning: no calls to throwing functions occur within 'try' expression
    guard (try? returnTrue()) != nil else {
                ^
0  swift                    0x000000010918947b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x0000000109188706 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000109189b4f SignalHandler(int) + 383
3  libsystem_platform.dylib 0x00007fff875aa52a _sigtramp + 26
4  swift                    0x0000000106a45ade swift::Lowering::TypeConverter::makeConstantInterfaceType(swift::SILDeclRef) + 1502
5  swift                    0x0000000106af3326 swift::Lowering::SILGenFunction::emitEpilog(swift::SILLocation, bool) + 86
6  swift                    0x0000000106b0dfec swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 412
7  swift                    0x0000000106aa69a3 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 1155
8  swift                    0x0000000106aaf4c2 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 210
9  swift                    0x0000000106aab22b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 683
10 swift                    0x0000000106aac2f7 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 903
11 swift                    0x0000000106aac815 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 117
12 swift                    0x0000000106826957 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 13895
13 swift                    0x00000001068224ce frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2814
14 swift                    0x000000010681d3cc main + 1532
15 libdyld.dylib            0x00007fff9166e5ad start + 1
@nevil
Copy link
Author

nevil commented Apr 28, 2016

The issue can be reproduced as below:

1) Put the code snippet in a file called SR-1333.swift.
2) In a shell, run "swiftc -o SR-1333 SR-1333.swift"

Result: Crash.

Output:

SR-1333.swift:6:17: warning: no calls to throwing functions occur within 'try' expression
    guard (try? returnTrue()) != nil else {
                ^
0  swift                    0x000000010e0bd66b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x000000010e0bc956 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x000000010e0bdccf SignalHandler(int) + 287
3  libsystem_platform.dylib 0x00007fff875aa52a _sigtramp + 26
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 2024102640
5  swift                    0x000000010c01e996 swift::Lowering::SILGenFunction::emitEpilog(swift::SILLocation, bool) + 86
6  swift                    0x000000010c03164a swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 362
7  swift                    0x000000010bfe74b1 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 1057
8  swift                    0x000000010bfec424 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 276
9  swift                    0x000000010bfebc6b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 731
10 swift                    0x000000010bfec7b9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 793
11 swift                    0x000000010bfecc23 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 115
12 swift                    0x000000010be10473 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 12627
13 swift                    0x000000010be0c7bd frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
14 swift                    0x000000010be081dc main + 1932
15 libdyld.dylib            0x00007fff9166e5ad start + 1
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file SR-1333.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -color-diagnostics -module-name main -o /var/folders/0l/kr96lmsd1wgbnq21nftllcwh0000gp/T/SR-1333-b3fbca.o
1.  While emitting SIL for 'crashFunction' at SR-1333.swift:5:1
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)

@tkrajacic
Copy link

Was about to file bug but searching turned up this one.
This still crashes in the latest Swift 3.1 snapshot. (org.swift.3120170217a)

@nevil
Copy link
Author

nevil commented May 16, 2017

Still happening with the latest 4.0 development snapshot: swift-4.0-DEVELOPMENT-SNAPSHOT-2017-05-11

@nevil
Copy link
Author

nevil commented Jul 12, 2017

Still crashing with swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-10-a.xctoolchain

Interestingly it does not crash when an incorrect "-swift-version" argument is provided.

:> /Library/Developer/Toolchains/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-10-a.xctoolchain/usr/bin/swiftc -o SR-1333 SR-1333.swift -swift-version 4.0
<unknown>:0: error: invalid value '4.0' in '-swift-version 4.0'
<unknown>:0: note: use major version, as in '-swift-version 4'
SR-1333.swift:6:17: warning: no calls to throwing functions occur within 'try' expression
    guard (try? returnTrue()) != nil else {
                ^

@swift-ci
Copy link
Collaborator

Comment by Kenneth Ackerson (JIRA)

Here is an Xcode project with some sample code that seems to cause this same issue as well help.zip

@jckarter
Copy link
Member

Kenny (JIRA User) reports that his example regressed from 3.1 to 4.0 as well.

@jckarter
Copy link
Member

@swift-ci create

@jckarter
Copy link
Member

PR for master: #11008
PR for 4.0: #11009

@jckarter
Copy link
Member

Merged to swift-4.0-branch as dd684ea.

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

No branches or pull requests

5 participants