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-14699] Out of order source ranges during code completion #57049

Closed
ahoppen opened this issue Jun 1, 2021 · 2 comments
Closed

[SR-14699] Out of order source ranges during code completion #57049

ahoppen opened this issue Jun 1, 2021 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Jun 1, 2021

Previous ID SR-14699
Radar rdar://78781163
Original Reporter @ahoppen
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug, FoundByStressTester
Assignee None
Priority Medium

md5: 73549dd4beb3d2bbd9bff15bee42389b

is duplicated by:

  • SR-14700 Out of source order during code completion after two subsequent requests

Issue Description:

The following test case produces an AST with out of order source ranges thus hits an assertion. This appears to be caused by the default member of FileManager.

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE

struct AppState {
    init() {
        let icloudDirectory #^COMPLETE^#= FileManager.default.url(forUbiquityContainerIdentifier: nil)
    }
    
    func archiveState() {}
}

Stack trace:

1.  While performing new completion
2.  While evaluating request CodeCompletionSecondPassRequest(source_file "/Users/alex/swift-src/swift/test/SourceKit/test.swift", )
3.  While evaluating request TypeCheckASTNodeAtLocRequest(0x7fd82a0f5f28 AbstractFunctionDecl name=init() : (no type set), )
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-ide-test           0x000000010e9c2c67 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-ide-test           0x000000010e9c1a88 llvm::sys::RunSignalHandlers() + 248
2  swift-ide-test           0x000000010e9c3296 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff20365d7d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603339975729824
5  libsystem_c.dylib        0x00007fff20275411 abort + 120
6  swift-ide-test           0x000000010eab048a swift::IterableDeclContext::addMemberSilently(swift::Decl*, swift::Decl*, bool) const::$_1::operator()(swift::Decl*, swift::Decl*) const (.cold.6) + 74
7  swift-ide-test           0x000000010a121315 swift::IterableDeclContext::addMemberSilently(swift::Decl*, swift::Decl*, bool) const::$_1::operator()(swift::Decl*, swift::Decl*) const + 357
8  swift-ide-test           0x000000010a121160 swift::IterableDeclContext::addMemberSilently(swift::Decl*, swift::Decl*, bool) const + 224
9  swift-ide-test           0x000000010a120ff2 swift::IterableDeclContext::addMember(swift::Decl*, swift::Decl*, bool) + 18
10 swift-ide-test           0x000000010a120800 swift::IterableDeclContext::loadAllMembers() const + 272
11 swift-ide-test           0x000000010a1206de swift::IterableDeclContext::getMembers() const + 14
12 swift-ide-test           0x0000000109ff5a77 swift::ast_scope::IterableTypeScope::expandBody(swift::ast_scope::ScopeCreator&) + 39
13 swift-ide-test           0x0000000109ff54df swift::ast_scope::IterableTypeBodyPortion::expandScope(swift::ast_scope::GenericTypeOrExtensionScope*, swift::ast_scope::ScopeCreator&) const + 31
14 swift-ide-test           0x0000000109ff2540 swift::ast_scope::ASTScopeImpl::expandAndBeCurrent(swift::ast_scope::ScopeCreator&) + 64
15 swift-ide-test           0x0000000109ff79aa swift::ast_scope::ASTScopeImpl::findInnermostEnclosingScope(swift::SourceLoc, swift::NullablePtr<llvm::raw_ostream>) + 90
16 swift-ide-test           0x0000000109ff24e2 swift::ASTScope::expandFunctionBody(swift::AbstractFunctionDecl*) + 66
17 swift-ide-test           0x000000010af507d4 swift::TypeCheckASTNodeAtLocRequest::evaluate(swift::Evaluator&, swift::DeclContext*, swift::SourceLoc) const + 196
18 swift-ide-test           0x000000010af8cff3 llvm::Expected<swift::TypeCheckASTNodeAtLocRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckASTNodeAtLocRequest>(swift::TypeCheckASTNodeAtLocRequest const&) + 243
19 swift-ide-test           0x000000010af86e37 swift::TypeCheckASTNodeAtLocRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckASTNodeAtLocRequest>(swift::Evaluator&, swift::TypeCheckASTNodeAtLocRequest, swift::TypeCheckASTNodeAtLocRequest::OutputType) + 55
20 swift-ide-test           0x000000010af86de1 swift::typeCheckASTNodeAtLoc(swift::DeclContext*, swift::SourceLoc) + 65
21 swift-ide-test           0x000000010a30e923 swift::ide::typeCheckContextAt(swift::DeclContext*, swift::SourceLoc) + 771
22 swift-ide-test           0x000000010a2e770b (anonymous namespace)::CodeCompletionCallbacksImpl::doneParsing() + 1211
23 swift-ide-test           0x000000010b1f97c8 swift::Parser::performCodeCompletionSecondPassImpl(swift::CodeCompletionDelayedDeclState&) + 888
24 swift-ide-test           0x000000010b1f9348 swift::CodeCompletionSecondPassRequest::evaluate(swift::Evaluator&, swift::SourceFile*, swift::CodeCompletionCallbacksFactory*) const + 232
25 swift-ide-test           0x000000010b203a1f llvm::Expected<swift::CodeCompletionSecondPassRequest::OutputType> swift::Evaluator::getResultUncached<swift::CodeCompletionSecondPassRequest>(swift::CodeCompletionSecondPassRequest const&) + 271
26 swift-ide-test           0x000000010b1f9157 swift::CodeCompletionSecondPassRequest::OutputType swift::evaluateOrDefault<swift::CodeCompletionSecondPassRequest>(swift::Evaluator&, swift::CodeCompletionSecondPassRequest, swift::CodeCompletionSecondPassRequest::OutputType) + 55
27 swift-ide-test           0x000000010a30cb01 swift::ide::CompletionInstance::performNewOperation(llvm::Optional<llvm::hash_code>, swift::CompilerInvocation&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, llvm::MemoryBuffer*, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, swift::DiagnosticConsumer*, llvm::function_ref<void (swift::CompilerInstance&, bool)>) + 529
28 swift-ide-test           0x000000010a30cf98 swift::ide::CompletionInstance::performOperation(swift::CompilerInvocation&, llvm::ArrayRef<char const*>, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, llvm::MemoryBuffer*, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, swift::DiagnosticConsumer*, llvm::function_ref<void (swift::CompilerInstance&, bool)>) + 680
29 swift-ide-test           0x0000000109f22ac0 doCodeCompletionImpl(swift::CodeCompletionCallbacksFactory*, swift::CompilerInvocation const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, bool) + 1376
30 swift-ide-test           0x0000000109f15560 main + 26144
31 libdyld.dylib            0x00007fff2033bf3d start + 1
@ahoppen
Copy link
Contributor Author

ahoppen commented Jun 21, 2021

The crash only happens in assert builds.

@ahoppen
Copy link
Contributor Author

ahoppen commented Jul 7, 2021

Fixed in #38036

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
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. code completion Area → source tooling: code completion found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

2 participants