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-11881] Compiler crash on callAsFunction with IUO #54296

Closed
hamishknight opened this issue Dec 2, 2019 · 1 comment
Closed

[SR-11881] Compiler crash on callAsFunction with IUO #54296

hamishknight opened this issue Dec 2, 2019 · 1 comment
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

@hamishknight
Copy link
Collaborator

Previous ID SR-11881
Radar None
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Swift version 5.1.1-dev (Swift d2e1f09)
Target: x86_64-apple-darwin18.5.0

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

md5: bd51860d6743bfe11914a2aeadc629af

Issue Description:

The following hits an assertion:

struct S {
  func callAsFunction(_ x: Int) -> Int! {
    return x
  }
}

func foo(_ x: S) {
  let y: Int = x(5)
}

Stack dump:

Unhandled coercion
UNREACHABLE executed at /Users/hamishknight/Desktop/swift-dev/swift/lib/Sema/CSApply.cpp:6405!
Stack dump:
0.  Program arguments: ./swift -frontend -typecheck /Users/hamishknight/Desktop/Stochastic Projects/newnew/newnew/main.swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -debug-diagnostic-names -disable-objc-attr-requires-foundation-module
1.  Swift version 5.1.1-dev (Swift d2e1f09169)
2.  While evaluating request TypeCheckFunctionBodyUntilRequest(main.(file).foo@/Users/hamishknight/Desktop/Stochastic Projects/newnew/newnew/main.swift:765:6, )
3.  While type-checking 'foo(_:)' (at /Users/hamishknight/Desktop/Stochastic Projects/newnew/newnew/main.swift:765:1)
4.  While type-checking statement at [/Users/hamishknight/Desktop/Stochastic Projects/newnew/newnew/main.swift:765:18 - line:767:1] RangeText="{
  let y: Int = x(5)
"
5.  While type-checking declaration 0x7f91c90175f8 (at /Users/hamishknight/Desktop/Stochastic Projects/newnew/newnew/main.swift:766:3)
6.  While type-checking expression at [/Users/hamishknight/Desktop/Stochastic Projects/newnew/newnew/main.swift:766:16 - line:766:19] RangeText="x(5"
0  swift                    0x000000010f582d95 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010f581d08 llvm::sys::RunSignalHandlers() + 248
2  swift                    0x000000010f583396 SignalHandler(int) + 278
3  libsystem_platform.dylib 0x00007fff7e5f0b5d _sigtramp + 29
4  swift                    0x000000011086a255 llvm::itanium_demangle::PixelVectorType::printLeft(llvm::itanium_demangle::OutputStream&) const (.cold.1) + 679877
5  libsystem_c.dylib        0x00007fff7e4b06a6 abort + 127
6  swift                    0x00000001107b59fe llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 462
7  swift                    0x000000010bebeeff (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder, llvm::Optional<swift::Pattern*>) + 9679
8  swift                    0x000000010bebf58f swift::constraints::Solution::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocator*, llvm::Optional<swift::Pattern*>) const + 319
9  swift                    0x000000010c029191 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*)::BindingListener::appliedSolution(swift::constraints::Solution&, swift::Expr*) + 49
10 swift                    0x000000010c01b047 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 967
11 swift                    0x000000010c01c5c3 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 1059
12 swift                    0x000000010c01c8b3 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 211
13 swift                    0x000000010c0522b5 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl*) + 2885
14 swift                    0x000000010c05020f (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 159
15 swift                    0x000000010c05015f swift::TypeChecker::typeCheckDecl(swift::Decl*) + 63
16 swift                    0x000000010c0b90a6 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 6854
17 swift                    0x000000010c0b6140 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 128
18 swift                    0x000000010c0b54bf swift::TypeCheckFunctionBodyUntilRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*, swift::SourceLoc) const + 1327
19 swift                    0x000000010c0b2805 swift::SimpleRequest<swift::TypeCheckFunctionBodyUntilRequest, bool (swift::AbstractFunctionDecl*, swift::SourceLoc), (swift::CacheKind)1>::evaluateRequest(swift::TypeCheckFunctionBodyUntilRequest const&, swift::Evaluator&) + 21
20 swift                    0x000000010c0bd1b7 llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyUntilRequest>(swift::TypeCheckFunctionBodyUntilRequest const&) + 391
21 swift                    0x000000010c0bccf0 llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyUntilRequest, (void*)0>(swift::TypeCheckFunctionBodyUntilRequest const&) + 240
22 swift                    0x000000010c0bbecb llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckFunctionBodyUntilRequest>(swift::TypeCheckFunctionBodyUntilRequest const&) + 107
23 swift                    0x000000010c0b5cd6 swift::TypeCheckFunctionBodyUntilRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyUntilRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyUntilRequest, swift::TypeCheckFunctionBodyUntilRequest::OutputType) + 38
24 swift                    0x000000010c0b4f22 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 66
25 swift                    0x000000010c0e2154 swift::performTypeChecking(swift::SourceFile&, unsigned int) + 548
26 swift                    0x000000010b80cbad swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t) + 413
27 swift                    0x000000010b80b852 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 418
28 swift                    0x000000010b80b0bd swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 621
29 swift                    0x000000010b5edbe6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 2022
30 swift                    0x000000010b5ec486 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3046
31 swift                    0x000000010b586f7e main + 734
32 libdyld.dylib            0x00007fff7e40b3d5 start + 1
33 libdyld.dylib            0x0000000000000008 start + 2176797748
fish: './swift -frontend -typecheck /U…' terminated by signal SIGABRT (Abort)
@hamishknight
Copy link
Collaborator Author

Fixed by #28519

@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

2 participants