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-9063] Compiler crash during diagnosis in swift::GenericContext::getGenericSignature() #51564

Closed
nathawes opened this issue Oct 23, 2018 · 2 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

Comments

@nathawes
Copy link
Collaborator

Previous ID SR-9063
Radar rdar://problem/45511837
Original Reporter @nathawes
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @nathawes
Priority Medium

md5: 9120437461ea20b2d365e336b3c3e444

Issue Description:

To reproduce, compile the below with the October 22 swift.org dev snapshot toolchain:

import Foundation

public protocol A: RawRepresentable {}
extension A {
  static func +(lhs: RawValue, rhs: Self) -> Self {
    return Self(rawValue: rhs + lhs.rawValue)!
  }
}

open class Foo<Bar: NSObject> {
  fileprivate var foobar: Bar {
    fatalError()
  }
  lazy var foo: () -> () = { [weak self] in
    guard let a = self else { return }
    _ = a.foobar + nil
  }
}

Here's the trace:

1.  While type-checking 'Foo' at /tmp/dasdasdf/dasdasdf/main.swift:18:6
2.  While type-checking declaration 0x7fe92f060050 at /tmp/dasdasdf/dasdasdf/main.swift:22:8
3.  While type-checking expression at [/tmp/dasdasdf/dasdasdf/main.swift:22:28 - line:25:3] RangeText="{ [weak self] in
    guard let a = self else { return }
    _ = a.foobar + nil
  "
4.  While type-checking statement at [/tmp/dasdasdf/dasdasdf/main.swift:22:28 - line:25:3] RangeText="{ [weak self] in
    guard let a = self else { return }
    _ = a.foobar + nil
  "
5.  While type-checking expression at [/tmp/dasdasdf/dasdasdf/main.swift:24:5 - line:24:20] RangeText="_ = a.foobar + "
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   swift                           0x000000010828c7a0 swift::GenericContext::getGenericSignature() const + 16
1   swift                           0x0000000107e756a0 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 5584
2   swift                           0x0000000107f158a7 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 1319
3   swift                           0x0000000107ecf408 swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 72
4   swift                           0x0000000107f70817 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 951
5   swift                           0x0000000107ffe1e8 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 584
6   swift                           0x0000000107ffd498 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 136
7   swift                           0x0000000107ffd24c swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 268
8   swift                           0x0000000107e4e02b swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool) + 555
9   swift                           0x0000000107f708cc swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1132
10  swift                           0x0000000107f75965 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, bool) + 357
11  swift                           0x0000000107f75c6b swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 315
12  swift                           0x0000000107f84d04 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 2484
13  swift                           0x0000000107f9120b (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 267
14  swift                           0x0000000107f8466e (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 798
15  swift                           0x0000000107f84346 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 38
16  swift                           0x000000010801def8 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 872
17  swift                           0x000000010782a53c swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t, swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 492
18  swift                           0x0000000107829173 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 435
19  swift                           0x0000000107828838 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 616
20  swift                           0x0000000106febc4d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1309
21  swift                           0x0000000106fea69d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
22  swift                           0x0000000106f9c6de main + 686
23  libdyld.dylib                   0x00007fff742fd085 start + 1
@nathawes
Copy link
Collaborator Author

@swift-ci create

@xedin
Copy link
Member

xedin commented Oct 25, 2018

Should be fixed by #20028

@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

3 participants