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-6517] Compiler crash when using type named Method #49067

Closed
NSExceptional opened this issue Dec 2, 2017 · 4 comments
Closed

[SR-6517] Compiler crash when using type named Method #49067

NSExceptional opened this issue Dec 2, 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

@NSExceptional
Copy link

Previous ID SR-6517
Radar rdar://problem/35830880
Original Reporter @NSExceptional
Type Bug
Status Resolved
Resolution Done

Attachment: Download

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

md5: 146fe062d4c99641151994d15c304d5b

Issue Description:

Seems to be caused by line 39, because removing or altering the call to .returnSelf() makes the crash disappear. Removing the method ivar access in .method() also removes the crash.

The crash is definitely dependent on the enum `Method` being called Method, and being a nested decl.

@belkadan
Copy link
Contributor

belkadan commented Dec 4, 2017

In the build log I see

<stdin>:32:44: error: cannot convert value of type 'Method' (aka 'OpaquePointer') to expected argument type 'Foo.Method'
        Foo().returnSelf(["": nil]).method(method)
                                           ^~~~~~

which explains the issue: Method is a type in the ObjectiveC module that doesn't match up with Foo.Method. It looks like the actual crash is in indexing, at least in a no-asserts build; it may turn out to be the type checker after all.

@belkadan
Copy link
Contributor

belkadan commented Dec 4, 2017

@swift-ci create

@belkadan
Copy link
Contributor

belkadan commented Dec 5, 2017

With a +asserts near-master compiler:

Index: Duplicate USR! s:s10DictionaryV3keyL_xvg
Index: Duplicate USR! s:s10DictionaryV3keyL_xvp
Index: Duplicate USR! s:s10DictionaryV3keyL_xvs
Index: Duplicate USR! c:objc(cs)NSObject(im)init

Assertion failed: (Index < Length && "Invalid index!"), function operator[], file /Volumes/Data/swift-public/llvm/include/llvm/ADT/ArrayRef.h, line 241.

6  swift                    0x000000010f54e885 (anonymous namespace)::SemaAnnotator::walkToExprPre(swift::Expr*) + 1573
7  swift                    0x000000010faa2031 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 161
8  swift                    0x000000010faa0cae swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 4910
9  swift                    0x000000010fa9fa81 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 257
10 swift                    0x000000010faa2063 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 211
11 swift                    0x000000010fa9fa81 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 257
12 swift                    0x000000010faa1fe6 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 86
13 swift                    0x000000010faa23dd swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 381
14 swift                    0x000000010faa485b (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 939
15 swift                    0x000000010fa9eff1 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 337
16 swift                    0x000000010faa439b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 571
17 swift                    0x000000010fa9efe4 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 324
18 swift                    0x000000010fa9ee8b swift::Decl::walk(swift::ASTWalker&) + 27
19 swift                    0x000000010fb3ab1a swift::SourceFile::walk(swift::ASTWalker&) + 170
20 swift                    0x000000010f54dac7 swift::SourceEntityWalker::walk(swift::SourceFile&) + 119
21 swift                    0x000000010f6ad16b (anonymous namespace)::IndexSwiftASTWalker::visitModule(swift::ModuleDecl&, llvm::StringRef) + 235
22 swift                    0x000000010f6acfdd swift::index::indexSourceFile(swift::SourceFile*, llvm::StringRef, swift::index::IndexDataConsumer&) + 477
23 swift                    0x000000010f6b5196 recordSourceFileUnit(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, llvm::ArrayRef<clang::FileEntry const*>, clang::CompilerInstance const&, swift::DiagnosticEngine&) + 1622
24 swift                    0x000000010f6b4b23 swift::index::indexAndRecord(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, swift::DependencyTracker const&) + 307
25 swift                    0x000000010ea01277 emitIndexData(swift::SourceFile*, swift::CompilerInvocation const&, swift::CompilerInstance&) + 247
26 swift                    0x000000010e9fe6bb performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 8235
27 swift                    0x000000010e9fb6b0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3376

1.  While walking into decl 'Bar' at /Users/jrose/Downloads/Crash-2/Crash/Thing.swift:29:8
2.  While walking into body of 'useArgOfMethodType(_:)' at /Users/jrose/Downloads/Crash-2/Crash/Thing.swift:30:5

@akyrtzi
Copy link
Member

akyrtzi commented Jan 11, 2018

Fixed via #13878

@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

4 participants