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-7663] Compiler crash regression when calling an initialiser in constrained extension #50203

Closed
hamishknight opened this issue May 11, 2018 · 4 comments
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.2 type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-7663
Radar rdar://problem/40165062
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0

Swift version 4.2-dev (LLVM d9cd6a5c49, Clang ed8876508e, Swift c363dad)
Target: x86_64-apple-darwin17.5.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression, CompilerCrash, TypeChecker
Assignee None
Priority Medium

md5: 138ffc917af8618ac53f03cac6f54c20

Issue Description:

The following yielded the compiler error "Generic parameter 'T' could not be inferred" in Swift 4.1, however it yields a segmentation fault on master (c363dad):

struct Foo<T, U> {

  var value: U

  func foob() -> Foo<T, U> {
    return Foo(value) // in 4.1: Generic parameter 'T' could not be inferred
  }
}

extension Foo where T == U {
  init(_ value: U)  {
    self.value = value
  }
}

Here's the stack trace:

0  swift                    0x00000001063d3698 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001063d3d26 SignalHandler(int) + 422
2  libsystem_platform.dylib 0x00007fff58f00f5a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000001 _sigtramp + 2802839745
4  swift                    0x0000000103c9e617 swift::GenericFunctionType::substGenericArgs(swift::SubstitutionMap const&) + 231
5  swift                    0x0000000103c9e522 swift::GenericFunctionType::substGenericArgs(llvm::ArrayRef<swift::Substitution>) + 34
6  swift                    0x000000010382cde6 swift::UncurriedCandidate::UncurriedCandidate(swift::ValueDecl*, unsigned int) + 230
7  swift                    0x000000010383083f swift::CalleeCandidateInfo::collectCalleeCandidates(swift::Expr*, bool) + 6671
8  swift                    0x00000001037e23d8 (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 2824
9  swift                    0x00000001037c6636 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 86
10 swift                    0x00000001037cbb78 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 3912
11 swift                    0x00000001038b35c8 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>) + 120
12 swift                    0x00000001038b6c58 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 872
13 swift                    0x000000010394795c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 7612
14 swift                    0x0000000103945ca9 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 265
15 swift                    0x0000000103944db5 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 85
16 swift                    0x0000000103944138 swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 328
17 swift                    0x0000000103944ca1 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 465
18 swift                    0x0000000103969ab2 typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 354
19 swift                    0x000000010396a9e8 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1848
20 swift                    0x00000001035aeabc swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 444
21 swift                    0x00000001035ad6d0 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 640
22 swift                    0x00000001035ad018 swift::CompilerInstance::performSema() + 472
23 swift                    0x00000001029eecf0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1904
24 swift                    0x00000001029ed576 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3318
25 swift                    0x00000001029a9e3d main + 2317
26 libdyld.dylib            0x00007fff58bf2015 start + 1
27 libdyld.dylib            0x000000000000000d start + 2806046713

and stack dump:

0.  Program arguments: /Users/Hamish/Desktop/swift-dev/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file /Users/Hamish/Dropbox/App Projects/Stack Overflow/how about it eh/how about it eh/main.swift -target x86_64-apple-darwin17.5.0 -enable-objc-interop -color-diagnostics -module-name null -o /var/folders/2s/m9mqt6bx6bsbfzt64whnsf080000gp/T/main-8a9336.o 
1.  While type-checking 'foob()' at /Users/Hamish/Dropbox/App Projects/Stack Overflow/how about it eh/how about it eh/main.swift:13:3
2.  While type-checking statement at [/Users/Hamish/Dropbox/App Projects/Stack Overflow/how about it eh/how about it eh/main.swift:13:28 - line:15:3] RangeText="{
    return Foo(value)
  }"
3.  While type-checking statement at [/Users/Hamish/Dropbox/App Projects/Stack Overflow/how about it eh/how about it eh/main.swift:14:5 - line:14:21] RangeText="return Foo(value)"
4.  While type-checking expression at [/Users/Hamish/Dropbox/App Projects/Stack Overflow/how about it eh/how about it eh/main.swift:14:12 - line:14:21] RangeText="Foo(value)"
@belkadan
Copy link
Contributor

@swift-ci create

@rudkx
Copy link
Member

rudkx commented May 15, 2018

I can reproduce this with a swift-4.2 Development snapshot, but not with my own build from master.

@xedin, is this something you might have fixed recently on master?

@xedin
Copy link
Member

xedin commented May 22, 2018

This issue has been fixed on master as a result of SubstitutionMap refactoring, which is too risky to cherry-pick to 4.2 unfortunately, so I'm just going to resolve this without cherry-picking.

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Jul 23, 2019

@hamishknight, Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

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

No branches or pull requests

5 participants