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-8000] Swift compiler reproducible segfault, appears to be related to type inference system #50533

Closed
swift-ci opened this issue Jun 14, 2018 · 4 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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8000
Radar rdar://problem/41161318
Original Reporter GarthSnyder (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

XCode Version 10.0 beta (10L176w)

High Sierra 10.13.6 Beta (17G31f)

 
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @xedin
Priority Medium

md5: 63d9bbf55562a0d7ab7bb64928aa860e

Issue Description:

100% reproducible for me - Xcode project attached. Just Build For Running. I'm sure this doesn't have anything specifically to do with PromiseKit, but that's the context in which I saw it, so this project includes PromiseKit (via Carthage). You might need to rebuild the framework first.

CompileSwift normal x86_64 /Users/garth/Work/TestSegfault/TestSegfault/AppDelegate.swift (in target: TestSegfault)

    cd /Users/garth/Work/TestSegfault
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/garth/Work/TestSegfault/TestSegfault/ViewController.swift -primary-file /Users/garth/Work/TestSegfault/TestSegfault/AppDelegate.swift -emit-module-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule -emit-module-doc-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate~partial.swiftdoc -serialize-diagnostics-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.dia -emit-dependencies-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.d -emit-reference-dependencies-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.swiftdeps -target x86_64-apple-ios12.0-simulator -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk -I /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Products/Debug-iphonesimulator -F /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Products/Debug-iphonesimulator -F /Users/garth/Work/TestSegfault/Carthage/Build/iOS -enable-testing -g -module-cache-path /Users/garth/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -working-directory -Xcc /Users/garth/Work/TestSegfault -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-generated-files.hmap -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-own-target-headers.hmap -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-all-target-headers.hmap -Xcc -iquote -Xcc /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-project-headers.hmap -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/DerivedSources/x86_64 -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/DerivedSources -Xcc -DDEBUG=1 -module-name TestSegfault -o /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.o -index-store-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Index/DataStore -index-system-modules
 
0  swift                    0x000000010d465c5a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010d465066 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff6775ff5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007ffee6541c48 _sigtramp + 2128485640
4  swift                    0x000000010a7319e9 (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 4793
5  swift                    0x000000010a710486 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 70
6  swift                    0x000000010a7437af swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 6207
7  swift                    0x000000010a847b7a swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 122
8  swift                    0x000000010a84825c swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1212
9  swift                    0x000000010a8de77e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 10334
10 swift                    0x000000010a8deefc swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 12252
11 swift                    0x000000010a8db03e swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 1294
12 swift                    0x000000010a8e08e8 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 872
13 swift                    0x000000010a9068c3 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2515
14 swift                    0x000000010a53d995 swift::CompilerInstance::performSema() + 4933
15 swift                    0x00000001097388db performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 731
16 swift                    0x000000010973510f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7839
17 swift                    0x00000001096dec48 main + 13144
18 libdyld.dylib            0x00007fff67451015 start + 1
Stack dump:
0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/garth/Work/TestSegfault/TestSegfault/ViewController.swift -primary-file /Users/garth/Work/TestSegfault/TestSegfault/AppDelegate.swift -emit-module-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule -emit-module-doc-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate~partial.swiftdoc -serialize-diagnostics-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.dia -emit-dependencies-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.d -emit-reference-dependencies-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.swiftdeps -target x86_64-apple-ios12.0-simulator -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk -I /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Products/Debug-iphonesimulator -F /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Products/Debug-iphonesimulator -F /Users/garth/Work/TestSegfault/Carthage/Build/iOS -enable-testing -g -module-cache-path /Users/garth/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -working-directory -Xcc /Users/garth/Work/TestSegfault -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-generated-files.hmap -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-own-target-headers.hmap -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-all-target-headers.hmap -Xcc -iquote -Xcc /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/TestSegfault-project-headers.hmap -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/DerivedSources/x86_64 -Xcc -I/Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/DerivedSources -Xcc -DDEBUG=1 -module-name TestSegfault -o /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Build/Intermediates.noindex/TestSegfault.build/Debug-iphonesimulator/TestSegfault.build/Objects-normal/x86_64/AppDelegate.o -index-store-path /Users/garth/Library/Developer/Xcode/DerivedData/TestSegfault-dzlfobagmypmbwfbyqfhjnbmwzmr/Index/DataStore -index-system-modules 
1. While type-checking 'testSegfault()' at /Users/garth/Work/TestSegfault/TestSegfault/AppDelegate.swift:17:5
2. While type-checking statement at [/Users/garth/Work/TestSegfault/TestSegfault/AppDelegate.swift:17:41 - line:23:5] RangeText="{
        let promise = Promise { seal in seal.fulfill(42) }
        return promise.recover { error in
            throw error
            return .value(Void)
        }
    }"
3. While type-checking statement at [/Users/garth/Work/TestSegfault/TestSegfault/AppDelegate.swift:19:9 - line:22:9] RangeText="return promise.recover { error in
            throw error
            return .value(Void)
        }"
4. While type-checking expression at [/Users/garth/Work/TestSegfault/TestSegfault/AppDelegate.swift:19:16 - line:22:9] RangeText="promise.recover { error in
            throw error
            return .value(Void)
        }"
error: Segmentation fault: 11
 
@belkadan
Copy link
Contributor

Thanks for a reproducible test case!

@swift-ci create

@xedin
Copy link
Member

xedin commented Feb 19, 2020

GarthSnyder (JIRA User) Could you please try with 11.4 beta and verify that this problem is fixed?

@swift-ci
Copy link
Collaborator Author

Comment by Garth Snyder (JIRA)

I gave it a shot, @xedin, but this bug report is a few Swift versions old and the current beta won't even attempt the original code for that reason. If I sub in the current version of PromiseKit, I do get a reasonable error message ("Generic parameter U could not be inferred") instead of a crash now.

@xedin
Copy link
Member

xedin commented Feb 19, 2020

Thank you! That's exactly what I did as well.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants