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-8555] CodeCompletion: EXC_BAD_ACCESS (SIGSEGV) – swift::Expr::getEndLoc #51073

Open
nathawes opened this issue Aug 16, 2018 · 5 comments
Open
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@nathawes
Copy link
Collaborator

Previous ID SR-8555
Radar rdar://problem/43395202
Original Reporter @nathawes
Type Bug
Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug, CompilerCrash
Assignee @rintaro
Priority Medium

md5: ed47d0bdd7a9a8cc52eff1f7fd8c716b

Issue Description:

With Xcode 10 beta 5 and the August 14 swift.org development toolchain the below steps crash SourceKitService:

git clone https://github.com/IBM-Swift/BlueSocket
cd BlueSocket
git checkout -f b0dcf15387be3641ecafea52f872fcd106cb644a 

Add a space then CodeComplete at BlueSocket/Sources/Socket.swift on line 420 after guard let family = ProtocolFamily

Thread 5 Crashed:0   com.apple.SourceKitService.4.2.2018081401_osx0x000000010743ccf7 swift::Expr::getEndLoc() const + 231   com.apple.SourceKitService.4.2.2018081401_osx0x00000001074c5e51 swift::StmtConditionElement::getSourceRange() const + 652   com.apple.SourceKitService.4.2.2018081401_osx0x00000001074c5f70 swift::StmtConditionElement::getEndLoc() const + 163   com.apple.SourceKitService.4.2.2018081401_osx0x000000010734090f swift::Parser::parseStmtGuard()::$_5::operator()(swift::ParserStatus, llvm::MutableArrayRef<swift::StmtConditionElement>) const + 2874   com.apple.SourceKitService.4.2.2018081401_osx0x000000010733bc74 swift::Parser::parseStmtGuard() + 4525   com.apple.SourceKitService.4.2.2018081401_osx0x0000000107337ceb swift::Parser::parseStmt() + 33076   com.apple.SourceKitService.4.2.2018081401_osx0x0000000107336baf swift::Parser::parseExprOrStmt(swift::ASTNode&) + 3037   com.apple.SourceKitService.4.2.2018081401_osx0x0000000107338fc4 swift::Parser::parseBraceItems(llvm::SmallVectorImpl<swift::ASTNode>&, swift::BraceItemListKind, swift::BraceItemListKind) + 27888   com.apple.SourceKitService.4.2.2018081401_osx0x000000010733e4c8 swift::Parser::parseBraceItemList(swift::Diag<>) + 3289   com.apple.SourceKitService.4.2.2018081401_osx0x000000010730b580 swift::Parser::parseAbstractFunctionBodyDelayed(swift::AbstractFunctionDecl*) + 110410  com.apple.SourceKitService.4.2.2018081401_osx0x0000000107332c6e (anonymous namespace)::ParseDelayedFunctionBodies::walkToDeclPre(swift::Decl*) + 28611  com.apple.SourceKitService.4.2.2018081401_osx0x00000001073e3c3b (anonymous namespace)::Traversal::doIt(swift::Decl*) + 17112  com.apple.SourceKitService.4.2.2018081401_osx0x00000001073e894b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 47513  com.apple.SourceKitService.4.2.2018081401_osx0x00000001073e3c68 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 21614  com.apple.SourceKitService.4.2.2018081401_osx0x00000001073e894b (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 47515  com.apple.SourceKitService.4.2.2018081401_osx0x00000001073e3c68 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 21616  com.apple.SourceKitService.4.2.2018081401_osx0x00000001073e3b7b swift::Decl::walk(swift::ASTWalker&) + 2717  com.apple.SourceKitService.4.2.2018081401_osx0x000000010749c36a swift::SourceFile::walk(swift::ASTWalker&) + 17018  com.apple.SourceKitService.4.2.2018081401_osx0x000000010749ac1f swift::ModuleDecl::walk(swift::ASTWalker&) + 9519  com.apple.SourceKitService.4.2.2018081401_osx0x000000010732b917 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 21520  com.apple.SourceKitService.4.2.2018081401_osx0x00000001069fc879 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 108121  com.apple.SourceKitService.4.2.2018081401_osx0x00000001069fbbd3 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 62722  com.apple.SourceKitService.4.2.2018081401_osx0x000000010687131f swiftCodeCompleteImpl(SourceKit::SwiftLangSupport&, llvm::MemoryBuffer*, unsigned int, (anonymous namespace)::SwiftCodeCompletionConsumer&, llvm::ArrayRef<char const*>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 215923  com.apple.SourceKitService.4.2.2018081401_osx0x0000000106870a43 SourceKit::SwiftLangSupport::codeComplete(llvm::MemoryBuffer*, unsigned int, SourceKit::CodeCompletionConsumer&, llvm::ArrayRef<char const*>) + 13124  com.apple.SourceKitService.4.2.2018081401_osx0x00000001068cc315 handleSemanticRequest(sourcekitd::RequestDict, std::__1::function<void (void*)>, sourcekitd_uid_s*, llvm::Optional<llvm::StringRef>, llvm::Optional<llvm::StringRef>, llvm::ArrayRef<char const*>) + 72525  com.apple.SourceKitService.4.2.2018081401_osx0x00000001068cbfc5 void SourceKit::WorkQueue::DispatchData::callAndDelete<handleRequestImpl(void*, std::__1::function<void (void*)>)::$_4>(void*) + 14926  libdispatch.dylib             0x00007fff5d9359a6 _dispatch_client_callout + 827  libdispatch.dylib             0x00007fff5d94624e _dispatch_block_invoke_direct + 26228  com.apple.SourceKitService.4.2.2018081401_osx0x00000001092db2af executeBlock(void*) + 1529  com.apple.SourceKitService.4.2.2018081401_osx0x000000010698af1d ExecuteOnThread_Dispatch(void*) + 1330  libsystem_pthread.dylib       0x00007fff5db74bc6 _pthread_body + 12831  libsystem_pthread.dylib       0x00007fff5db74b32 _pthread_start + 7032  libsystem_pthread.dylib       0x00007fff5db746f9 thread_start + 13 
@nathawes
Copy link
Collaborator Author

@swift-ci create

@rintaro
Copy link
Mannequin

rintaro mannequin commented Aug 17, 2018

@nathawes

BlueSocket/Sources/Socket.swift:34:8

I'm not able to reproduce this.
https://github.com/IBM-Swift/BlueSocket/blob/b0dcf15387be3641ecafea52f872fcd106cb644a/Sources/Socket.swift#L34

public  #^COMPLETE^#class Socket: SocketReader, SocketWriter {

Could you confirm?

@rintaro
Copy link
Mannequin

rintaro mannequin commented Aug 17, 2018

Reproduced with:

guard let _ = Foo#^COMPLETE^# else { }

Sigh. This is definitely mine 🙁

@nathawes
Copy link
Collaborator Author

I got very mixed up with the line and column, sorry! It should've been 420:40. I'll fix it up.

I saw this one in several projects following if/while/guard let.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Aug 17, 2018

Thanks!
Fix: #18783

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added crash Bug: A crash, i.e., an abnormal termination of software compiler The Swift compiler in itself labels Dec 12, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
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. code completion Area → source tooling: code completion compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

2 participants