Commit 6e6f5547 authored by Milian Wolff's avatar Milian Wolff
Browse files

Port to new PersistentSymbolTable API

parent f7697caf
Pipeline #205524 failed with stage
in 1 minute and 37 seconds
......@@ -219,47 +219,45 @@ DeclarationPointer findDeclarationImportHelper(DUContext* currentContext, const
DeclarationPointer findDeclarationInPST(DUContext* currentContext, QualifiedIdentifier id, DeclarationType declarationType)
{
DeclarationPointer ret;
ifDebug(qCDebug(DUCHAIN) << "PST: " << id.toString() << declarationType;)
uint nr;
const IndexedDeclaration* declarations = nullptr;
DUChainWriteLocker wlock;
PersistentSymbolTable::self().declarations(id, nr, declarations);
ifDebug(qCDebug(DUCHAIN) << "found declarations:" << nr;)
/// Indexed string for 'Php', identifies environment files from this language plugin
static const IndexedString phpLangString("Php");
for (uint i = 0; i < nr; ++i) {
ParsingEnvironmentFilePointer env = DUChain::self()->environmentFileForDocument(declarations[i].indexedTopContext());
auto visitor = [&](const IndexedDeclaration &indexedDeclaration) {
ParsingEnvironmentFilePointer env = DUChain::self()->environmentFileForDocument(indexedDeclaration.indexedTopContext());
if(!env) {
ifDebug(qCDebug(DUCHAIN) << "skipping declaration, missing meta-data";)
continue;
return PersistentSymbolTable::VisitorState::Continue;
}
if(env->language() != phpLangString) {
ifDebug(qCDebug(DUCHAIN) << "skipping declaration, invalid language" << env->language().str();)
continue;
return PersistentSymbolTable::VisitorState::Continue;
}
if (!declarations[i].declaration()) {
const auto declaration = indexedDeclaration.declaration();
if (!declaration) {
ifDebug(qCDebug(DUCHAIN) << "skipping declaration, doesn't have declaration";)
continue;
} else if (!isMatch(declarations[i].declaration(), declarationType)) {
return PersistentSymbolTable::VisitorState::Continue;
} else if (!isMatch(declaration, declarationType)) {
ifDebug(qCDebug(DUCHAIN) << "skipping declaration, doesn't match with declarationType";)
continue;
return PersistentSymbolTable::VisitorState::Continue;
}
TopDUContext* top = declarations[i].declaration()->context()->topContext();
TopDUContext* top = declaration->context()->topContext();
currentContext->topContext()->addImportedParentContext(top);
currentContext->topContext()->parsingEnvironmentFile()
->addModificationRevisions(top->parsingEnvironmentFile()->allModificationRevisions());
currentContext->topContext()->updateImportsCache();
ifDebug(qCDebug(DUCHAIN) << "using" << declarations[i].declaration()->toString() << top->url();)
wlock.unlock();
return DeclarationPointer(declarations[i].declaration());
}
ret = declaration;
return PersistentSymbolTable::VisitorState::Break;
};
PersistentSymbolTable::self().visitDeclarations(id, visitor);
wlock.unlock();
ifDebug(qCDebug(DUCHAIN) << "returning 0";)
return DeclarationPointer();
return ret;
}
QByteArray formatComment(AstNode* node, EditorIntegrator* editor)
......
  • @mwolff Hey! 🙂 I saw that in master the uses test is failing (timing out after 60 seconds) and from what I can tell from the CI system it seems to be tracing back to this commit. Would you have time to take a look perhaps?

  • @wiesinger replicated, and indeed it's a deadlock in the code:

    (gdb) bt
    #0  0x00007ffff2b1959d in syscall () at /usr/lib/libc.so.6
    #1  0x00007ffff30dfb06 in QBasicMutex::lockInternal() () at /usr/lib/libQt5Core.so.5
    #2  0x00007ffff5c95d87 in QMutexLocker::QMutexLocker(QBasicMutex*) (this=0x7fffffff7808, m=0x7ffff75ede50 <KDevelop::ItemRepositoryFor<KDevelop::PersistentSymbolTable>::repo()::mutex>)
        at /usr/include/qt/QtCore/qmutex.h:238
    #3  0x00007ffff5dc0d0e in KDevelop::LockedItemRepository::write<KDevelop::PersistentSymbolTable, KDevelop::PersistentSymbolTable::visitFilteredDeclarations(const KDevelop::IndexedQualifiedIdentifier&, const KDevelop::TopDUContext::IndexedRecursiveImports&, const DeclarationVisitor&) const::<lambda(KDevelop::(anonymous namespace)::PersistentSymbolTableRepo&)> >(struct {...} &&) (op=...) at /home/milian/projects/kde/src/kdevelop/kdevplatform/serialization/itemrepository.h:2310
    #4  0x00007ffff5dc0df8 in KDevelop::PersistentSymbolTable::visitFilteredDeclarations(KDevelop::IndexedQualifiedIdentifier const&, Utils::StorableSet<KDevelop::IndexedTopDUContext, KDevelop::IndexedTopDUContextIndexConversion, KDevelop::RecursiveImportRepository, true, Utils::DummyLocker> const&, std::function<KDevelop::PersistentSymbolTable::VisitorState (KDevelop::IndexedDeclaration const&)> const&) const (this=0x7ffff77ec5c8 <KDevelop::PersistentSymbolTable::self()::ret>, id=..., visibility=..., visitor=...)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/persistentsymboltable.cpp:361
    #5  0x00007ffff5d2eb11 in KDevelop::TopDUContext::FindDeclarationsAcceptor::operator()(KDevelop::QualifiedIdentifier const&) (this=0x7fffffff8ff0, id=...)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/topducontext.cpp:688
    #6  0x00007ffff5d3542c in KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const (this=0x555555b80260, previous=..., identifier=..., accept=..., position=..., canBeNamespace=false, buddy=0x7fffffff7b00, recursionDepth=1)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/topducontext.cpp:857
    #7  0x00007ffff5d34aed in KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const::{lambda(KDevelop::IndexedDeclaration const&)#1}::operator()(KDevelop::IndexedDeclaration const&) const (__closure=0x555555a86fe0, indexedAliasDecl=...)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/topducontext.cpp:839
    #8  0x00007ffff5d3becf in std::__invoke_impl<KDevelop::PersistentSymbolTable::VisitorState, KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const::{lambda(KDevelop::IndexedDeclaration const&)#1}&, KDevelop::IndexedDeclaration const&>(std::__invoke_other, KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const::{lambda(KDevelop::IndexedDeclaration const&)#1}&, KDevelop::IndexedDeclaration const&) (__f=...) at /usr/include/c++/12.2.0/bits/invoke.h:61
    #9  0x00007ffff5d3b932 in std::__invoke_r<KDevelop::PersistentSymbolTable::VisitorState, KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const::{lambda(KDevelop::IndexedDeclaration const&)#1}&, KDevelop::IndexedDeclaration const&>(KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const::{lambda(KDevelop::IndexedDeclaration const&)#1}&, KDevelop::IndexedDeclaration const&) (__fn=...) at /usr/include/c++/12.2.0/bits/invoke.h:114
    #10 0x00007ffff5d3adbe in std::_Function_handler<KDevelop::PersistentSymbolTable::VisitorState (KDevelop::IndexedDeclaration const&), KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const::{lambda(KDevelop::IndexedDeclaration const&)#1}>::_M_invoke(std::_Any_data const&, KDevelop::IndexedDeclaration const&) (__functor=..., __args#0=...) at /usr/include/c++/12.2.0/bits/std_function.h:290
    #11 0x00007ffff5dcf371 in std::function<KDevelop::PersistentSymbolTable::VisitorState (KDevelop::IndexedDeclaration const&)>::operator()(KDevelop::IndexedDeclaration const&) const
        (this=0x7fffffff8ed0, __args#0=...) at /usr/include/c++/12.2.0/bits/std_function.h:591
    #12 0x00007ffff5dc0c5d in operator()(KDevelop::(anonymous namespace)::PersistentSymbolTableRepo&) const (__closure=0x7fffffff8d70, repo=...)
    #13 0x00007ffff5dc0d21 in KDevelop::LockedItemRepository::write<KDevelop::PersistentSymbolTable, KDevelop::PersistentSymbolTable::visitFilteredDeclarations(const KDevelop::IndexedQualifiedIdentifier&, const KDevelop::TopDUContext::IndexedRecursiveImports&, const DeclarationVisitor&) const::<lambda(KDevelop::(anonymous namespace)::PersistentSymbolTableRepo&)> >(struct {...} &&) (op=...) at /home/milian/projects/kde/src/kdevelop/kdevplatform/serialization/itemrepository.h:2311
    #14 0x00007ffff5dc0df8 in KDevelop::PersistentSymbolTable::visitFilteredDeclarations(KDevelop::IndexedQualifiedIdentifier const&, Utils::StorableSet<KDevelop::IndexedTopDUContext, KDevelop::IndexedTopDUContextIndexConversion, KDevelop::RecursiveImportRepository, true, Utils::DummyLocker> const&, std::function<KDevelop::PersistentSymbolTable::VisitorState (KDevelop::IndexedDeclaration const&)> const&) const (this=0x7ffff77ec5c8 <KDevelop::PersistentSymbolTable::self()::ret>, id=..., visibility=..., visitor=...)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/persistentsymboltable.cpp:361
    #15 0x00007ffff5d35372 in KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevelop::QualifiedIdentifier const&, QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool, KDevelop::TopDUContext::ApplyAliasesBuddyInfo*, unsigned int) const (this=0x555555b80260, previous=..., identifier=..., accept=..., position=..., canBeNamespace=false, buddy=0x0, recursionDepth=0)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/topducontext.cpp:795
    #16 0x00007ffff5d30e98 in KDevelop::TopDUContext::applyAliases<KDevelop::TopDUContext::FindDeclarationsAcceptor>(KDevVarLengthArray<QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem>, 256> const&, KDevelop::TopDUContext::FindDeclarationsAcceptor&, KDevelop::CursorInRevision const&, bool) const
        (this=0x555555b80260, identifiers=..., acceptor=..., position=..., canBeNamespace=false) at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/topducontext.cpp:942
    #17 0x00007ffff5d2b2fe in KDevelop::TopDUContext::findDeclarationsInternal(KDevVarLengthArray<QExplicitlySharedDataPointer<KDevelop::DUContext::SearchItem>, 256> const&, KDevelop::CursorInRevision const&, KDevelop::TypePtr<KDevelop::AbstractType> const&, QList<KDevelop::Declaration*>&, KDevelop::TopDUContext const*, QFlags<KDevelop::DUContext::SearchFlag>, unsigned int) const (this=0x555555b80260, identifiers=..., position=..., dataType=..., ret=QList<KDevelop::Declaration *> (size = 0), flags=...)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/topducontext.cpp:724
    #18 0x00007ffff5d00345 in KDevelop::DUContext::findDeclarations(KDevelop::QualifiedIdentifier const&, KDevelop::CursorInRevision const&, KDevelop::TypePtr<KDevelop::AbstractType> const&, KDevelop::TopDUContext const*, QFlags<KDevelop::DUContext::SearchFlag>) const (this=0x555555b80260, identifier=..., position=..., dataType=..., topContext=0x0, flags=...)
        at /home/milian/projects/kde/src/kdevelop/kdevplatform/language/duchain/ducontext.cpp:793
    ...

    I'll try to fix it

    Edited by Milian Wolff
  • Thank you! 🙂

Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment