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-6660] Compiler crash when #selector refers to a protocol property requirement #49209

Closed
hamishknight opened this issue Dec 22, 2017 · 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

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-6660
Radar rdar://problem/36256336
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Cannot Reproduce
Environment

Swift version 4.1-dev (LLVM 495a6e5380, Clang af0579122e, Swift 476e41a)
Target: x86_64-apple-darwin17.3.0

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

md5: 25ce99f749e42763c52ca22610f6c6b7

Issue Description:

The following crashes the compiler:

import Foundation

@objc protocol P {
  var f: String { get }
}

let s = #selector(getter: P.f)

It triggers an assertion in ASTVerifier.cpp verifyChecked(MemberRefExpr *E), here's the message + stack trace:

Member reference into an unopened existential type
(member_ref_expr type='(P) -> String' location=/Users/Hamish/Desktop/foo.swift:7:29 range=[/Users/Hamish/Desktop/foo.swift:7:27 - line:7:29] decl=foo.(file).P.f@/Users/Hamish/Desktop/foo.swift:4:7 [with P[abstract:P]]
  (unevaluated_instance implicit type='(P)' location=/Users/Hamish/Desktop/foo.swift:7:27 range=[/Users/Hamish/Desktop/foo.swift:7:27 - line:7:27]
    (metatype_conversion_expr implicit type='(P).Protocol' location=/Users/Hamish/Desktop/foo.swift:7:27 range=[/Users/Hamish/Desktop/foo.swift:7:27 - line:7:27]
      (opaque_value_expr implicit type='(P).Type' location=/Users/Hamish/Desktop/foo.swift:7:27 range=[/Users/Hamish/Desktop/foo.swift:7:27 - line:7:27] @ 0x7fb68d814a08))))
0  swift                    0x00000001083b94e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001083b8436 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x00000001083b9aae SignalHandler(int) + 366
3  libsystem_platform.dylib 0x00007fff760cdf5a _sigtramp + 26
4  swift                    0x000000010928ca98 (anonymous namespace)::DarwinX86AsmBackend::getCompactUnwindRegNum(unsigned int) const::CU64BitRegs + 201630
5  libsystem_c.dylib        0x00007fff75ef8312 abort + 127
6  swift                    0x0000000105cb2414 (anonymous namespace)::Verifier::verifyChecked(swift::MemberRefExpr*) + 292
7  swift                    0x0000000105ca8b49 swift::MemberRefExpr* (anonymous namespace)::Verifier::dispatchVisitPost<swift::MemberRefExpr*>(swift::MemberRefExpr*) + 297
8  swift                    0x0000000105c93e61 (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 817
9  swift                    0x0000000105cd6536 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 134
10 swift                    0x0000000105cd8dde (anonymous namespace)::Traversal::visitOpenExistentialExpr(swift::OpenExistentialExpr*) + 94
11 swift                    0x0000000105cd71b4 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 1380
12 swift                    0x0000000105cd6c06 (anonymous namespace)::Traversal::visit(swift::Expr*) + 70
13 swift                    0x0000000105cd6510 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 96
14 swift                    0x0000000105cd9c60 (anonymous namespace)::Traversal::visitObjCSelectorExpr(swift::ObjCSelectorExpr*) + 48
15 swift                    0x0000000105cd7684 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 2612
16 swift                    0x0000000105cd6c06 (anonymous namespace)::Traversal::visit(swift::Expr*) + 70
17 swift                    0x0000000105cd6510 (anonymous namespace)::Traversal::doIt(swift::Expr*) + 96
18 swift                    0x0000000105ce1608 (anonymous namespace)::Traversal::visitPatternBindingDecl(swift::PatternBindingDecl*) + 328
19 swift                    0x0000000105ce0e86 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 150
20 swift                    0x0000000105ce0d66 (anonymous namespace)::Traversal::visit(swift::Decl*) + 70
21 swift                    0x0000000105cd6aea (anonymous namespace)::Traversal::doIt(swift::Decl*) + 122
22 swift                    0x0000000105cdd288 (anonymous namespace)::Traversal::visitBraceStmt(swift::BraceStmt*) + 328
23 swift                    0x0000000105cdce8c swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 92
24 swift                    0x0000000105cdcde6 (anonymous namespace)::Traversal::visit(swift::Stmt*) + 70
25 swift                    0x0000000105cd6601 (anonymous namespace)::Traversal::doIt(swift::Stmt*) + 97
26 swift                    0x0000000105ce1720 (anonymous namespace)::Traversal::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 48
27 swift                    0x0000000105ce0ec0 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 208
28 swift                    0x0000000105ce0d66 (anonymous namespace)::Traversal::visit(swift::Decl*) + 70
29 swift                    0x0000000105cd6aea (anonymous namespace)::Traversal::doIt(swift::Decl*) + 122
30 swift                    0x0000000105cd6a60 swift::Decl::walk(swift::ASTWalker&) + 64
31 swift                    0x0000000105edf39d swift::SourceFile::walk(swift::ASTWalker&) + 525
32 swift                    0x0000000105c921c6 swift::verify(swift::SourceFile&) + 150
33 swift                    0x000000010569f701 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 2033
34 swift                    0x0000000104d247bf swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 927
35 swift                    0x0000000104d20659 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 697
36 swift                    0x0000000104d1fe09 swift::CompilerInstance::performSema() + 1801
37 swift                    0x0000000103ae2fb1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 4817
38 swift                    0x0000000103adfab3 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 8883
39 swift                    0x0000000103a08eb3 main + 4819
40 libdyld.dylib            0x00007fff75e4c115 start + 1
41 libdyld.dylib            0x000000000000000a start + 2317041398
@belkadan
Copy link
Contributor

belkadan commented Jan 2, 2018

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Jan 4, 2018

Reproduced on master.

@ahoppen, interested in taking a look at this? It looks like you implemented the original functionality.

@ahoppen
Copy link
Contributor

ahoppen commented Jan 9, 2018

@DougGregor ended up finishing the implementation because I ran out of time back tehn. From what I saw on first glimpse, the issue is caused by an AST structure he created and I don't currently have time to look deeper into it.

@ahoppen
Copy link
Contributor

ahoppen commented Jun 25, 2021

Doesn’t reproduce on main anymore.

@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

5 participants