1. 07 Aug, 2022 1 commit
  2. 29 Jul, 2022 1 commit
  3. 27 Jul, 2022 2 commits
    • Igor Kushnir's avatar
      Don't clear the persistent symbol table cache early · 56e8e9ec
      Igor Kushnir authored
      DUChainPrivate::doMoreCleanup() clears the cache before the destruction
      of objects with static object duration. The crash described in
      a8ffba2c indicates that the cache is
      filled again afterwards. So the only effect of clearing the cache seems
      to be slower exit because of more cache misses.
      56e8e9ec
    • Igor Kushnir's avatar
      Destroy RecursiveImportCacheRepository after PersistentSymbolTableRepo · e1541088
      Igor Kushnir authored
      a8ffba2c cleared the persistent symbol
      table caches in ~PersistentSymbolTable() to work around an
      AddressSanitizer crash when a non-empty imports cache is destroyed after
      the cache repository it references.
      
      The constructor of the PersistentSymbolTable singleton creates a
      PersistentSymbolTableRepo function-local static, then a
      RecursiveImportCacheRepository function-local static. The order of
      destruction of these 3 static objects is the reverse of the order of
      their construction completion:
      ~PersistentSymbolTable()
      recursiveImportCacheRepositoryObject's destruction
      ~PersistentSymbolTableRepo()
      
      Since PersistentSymbolTableRepo::importsCache depends on
      recursiveImportCacheRepositoryObject and not vice versa, a proper fix is
      to create the cache repository before and thus destroy after the
      persistent symbol table repository.
      e1541088
  4. 25 Jul, 2022 4 commits
  5. 23 Jul, 2022 1 commit
  6. 15 Jul, 2022 11 commits
    • Milian Wolff's avatar
      Don't crash on exit when clearing PersistentSymbolTable caches · a8ffba2c
      Milian Wolff authored
      Instead clear the cache early when the PersistentSymbolTable is
      destroyed, not only once we destroy the repository. At the latter
      stage, the items referenced by the cache might be gone already,
      leading to crashes such as:
      
      ```
      =================================================================
      ==25768==ERROR: AddressSanitizer: heap-use-after-free on address 0x60b000089bb4 at pc 0x7effefaf1018 bp 0x7ffea79d94c0 sp 0x7ffea79d94b8
      READ of size 4 at 0x60b000089bb4 thread T0
          #0 0x7effefaf1017 in QVector<KDevelop::Bucket<Utils::SetNodeData, Utils::SetNodeDataRequest, false, 24u>*>::size() const /usr/include/qt5/QtCore/qvector.h:88
          #1 0x7effefaf1d45 in KDevelop::ItemRepository<Utils::SetNodeData, Utils::SetNodeDataRequest, false, QRecursiveMutex, 24u, 1048576u>::verifyIndex(unsigned int) const /builds/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h:2252
          #2 0x7efff0157ad7 in KDevelop::ItemRepository<Utils::SetNodeData, Utils::SetNodeDataRequest, false, QRecursiveMutex, 24u, 1048576u>::dynamicItemFromIndexSimple(unsigned int) /builds/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h:1533
          #3 0x7efff014e331 in Utils::Set::unrefNode(unsigned int) /builds/kdevelop/kdevelop/kdevplatform/language/util/setrepository.cpp:1143
          #4 0x7efff014e7d2 in Utils::Set::staticUnref() /builds/kdevelop/kdevelop/kdevplatform/language/util/setrepository.cpp:1173
          #5 0x7effeff064c7 in ~StorableSet /builds/kdevelop/kdevelop/kdevplatform/language/util/setrepository.h:187
          #6 0x7effeff1e8d5 in ~QHashNode /usr/include/qt5/QtCore/qhash.h:147
          #7 0x7effeff1e951 in deleteNode2 /usr/include/qt5/QtCore/qhash.h:595
          #8 0x7effde12975b in QHashData::free_helper(void (*)(QHashData::Node*)) (/lib64/libQt5Core.so.5+0x13175b)
          #9 0x7effeff0b679 in freeData /usr/include/qt5/QtCore/qhash.h:619
          #10 0x7effeff014e7 in ~QHash /usr/include/qt5/QtCore/qhash.h:250
          #11 0x7effeff28264 in ~PersistentSymbolTableRepo /builds/kdevelop/kdevelop/kdevplatform/language/duchain/persistentsymboltable.cpp:192
          #12 0x7effddaef104 in __run_exit_handlers (/lib64/libc.so.6+0x59104)
          #13 0x7effddaef28f in exit (/lib64/libc.so.6+0x5928f)
          #14 0x7effddad65b6 in __libc_start_call_main (/lib64/libc.so.6+0x405b6)
          #15 0x7effddad6678 in __libc_start_main_alias_1 (/lib64/libc.so.6+0x40678)
          #16 0x407ed4 in _start (/builds/kdevelop/kdevelop/_build/bin/test_files+0x407ed4)
      
      0x60b000089bb4 is located 4 bytes inside of 104-byte region [0x60b000089bb0,0x60b000089c18)
      freed by thread T0 here:
          #0 0x7efff53080c8  (/lib64/libasan.so.8+0xbb0c8)
          #1 0x7effefb07210 in QTypedArrayData<KDevelop::Bucket<Utils::SetNodeData, Utils::SetNodeDataRequest, false, 24u>*>::deallocate(QArrayData*) /usr/include/qt5/QtCore/qarraydata.h:240
          #2 0x7effefafe448 in QVector<KDevelop::Bucket<Utils::SetNodeData, Utils::SetNodeDataRequest, false, 24u>*>::freeData(QTypedArrayData<KDevelop::Bucket<Utils::SetNodeData, Utils::SetNodeDataRequest, false, 24u>*>*) /usr/include/qt5/QtCore/qvector.h:579
          #3 0x7efff0158e5f in QVector<KDevelop::Bucket<Utils::SetNodeData, Utils::SetNodeDataRequest, false, 24u>*>::~QVector() /usr/include/qt5/QtCore/qvector.h:73
          #4 0x7efff0151888 in KDevelop::ItemRepository<Utils::SetNodeData, Utils::SetNodeDataRequest, false, QRecursiveMutex, 24u, 1048576u>::~ItemRepository() /builds/kdevelop/kdevelop/kdevplatform/serialization/itemrepository.h:1128
          #5 0x7efff01673f6 in Utils::SetDataRepository::~SetDataRepository() /builds/kdevelop/kdevelop/kdevplatform/language/util/basicsetrepository.h:178
          #6 0x7efff014b9f4 in Utils::BasicSetRepository::~BasicSetRepository() /builds/kdevelop/kdevelop/kdevplatform/language/util/setrepository.cpp:987
          #7 0x7effddaef104 in __run_exit_handlers (/lib64/libc.so.6+0x59104)
      ```
      a8ffba2c
    • Igor Kushnir's avatar
      .clang-format: disable formatting in 3rdparty directories · 38295d73
      Igor Kushnir authored and Milian Wolff's avatar Milian Wolff committed
      38295d73
    • Igor Kushnir's avatar
      .clang-format: follow KDevelop's uncrustify config · 21f74610
      Igor Kushnir authored and Milian Wolff's avatar Milian Wolff committed
      Large parts of KDevelop's code were reformatted in 2018 using
      uncrustify (search for commit messages containing "uncrustify").
      Bringing .clang-format as close as possible to format.config.uncrustify
      is going to minimize diff during a future reformatting.
      21f74610
    • Igor Kushnir's avatar
      .clang-format: don't sort includes (temporarily) · f62fa3f6
      Igor Kushnir authored and Milian Wolff's avatar Milian Wolff committed
      See e8987f58 for the explanation.
      f62fa3f6
    • Igor Kushnir's avatar
      .clang-format: don't move args&params to own lines · 835ebace
      Igor Kushnir authored and Milian Wolff's avatar Milian Wolff committed
      835ebace
    • Igor Kushnir's avatar
      .clang-format: don't break before namespace brace · d5b28964
      Igor Kushnir authored and Milian Wolff's avatar Milian Wolff committed
      No non-Custom BreakBeforeBraces value fits the KDevelop code style:
      * "Linux" breaks before brace on namespace definition;
      * "Mozilla" breaks before brace on enum definition;
      * "WebKit" doesn't break before brace on class definition.
      d5b28964
    • Igor Kushnir's avatar
      .clang-format: restore KDevelop-specific formatting options · 5ed015b3
      Igor Kushnir authored and Milian Wolff's avatar Milian Wolff committed
      5ed015b3
    • Igor Kushnir's avatar
      Replace our .clang-format with the KF5 version · 5363ca50
      Igor Kushnir authored and Milian Wolff's avatar Milian Wolff committed
      Copy the following file verbatim into .clang-format:
      https://commits.kde.org/extra-cmake-modules?path=kde-modules/clang-format.cmake
      5363ca50
    • Milian Wolff's avatar
      Cleanup: Remove CacheEntry in PersistentSymbolTable · a1865644
      Milian Wolff authored
      Instead give better names to the typedefs and use them directly.
      a1865644
    • Milian Wolff's avatar
      Unify template arguments for ItemRepositoryFor · 9a28e06d
      Milian Wolff authored
      The type we was is just a context, it doesn't have to be the item.
      Unify on the non-item class for which the repository is used, or
      introduce a separate context type tag where none exists. This allows
      for shorter callee code.
      
      Note that the separate type tag is already an established paradigm
      which was used previously for the DeclarationComment e.g.
      
      Fixes: kdevelop/kdevelop#9
      9a28e06d
    • Milian Wolff's avatar
      Refactor the PersistentSymbolTable API to prevent unsafe access · 56f3cc14
      Milian Wolff authored
      Instead of handing out raw iterators to data that is stored within
      the symbol table, force users to pass a visitor instead.
      
      This has the nice side effect that we can hide way more of the
      persistent symbol table internals. We can now also get rid of the
      extra mutex for the caches, as we only touch them while we have
      the repository mutex locked.
      
      The downside is that the callee loops are all a bit more tedious
      to write, as we can't just `break` or `continue` directly anymore
      and instead have to return a special `Break` or `Continue` value
      from the visitor instead.
      
      Fixes: kdevelop/kdevelop#10
      56f3cc14
  7. 14 Jul, 2022 5 commits
    • Milian Wolff's avatar
      Validate declaration before access · 5a246795
      Milian Wolff authored
      The PersistentSymbolTable stores IndexedDeclarations, we should
      validate the validity of the Declaration before use - potentially
      the declaration isn't valid anymore.
      5a246795
    • Milian Wolff's avatar
      Use `Declaration*` directly, no need for DeclarationPointer here · 05889f37
      Milian Wolff authored
      We do not unlock the mutex thus the declaration pointer will
      remain valid and we don't need to go through the DeclarationPointer
      here at all.
      05889f37
    • Milian Wolff's avatar
      Actually iterate over all declarations from PersistentSymbolTable · 20bc9db9
      Milian Wolff authored
      The code in DocumentClassesFolder::updateDocument accidentally (?)
      only ever checked the very first declaration returned by the symbol
      table. This has to be wrong, fix the code to actually iterate over
      all returned declarations.
      20bc9db9
    • Milian Wolff's avatar
      Fix compile on Windows · 08de627b
      Milian Wolff authored
      08de627b
    • Igor Kushnir's avatar
      Documentation: don't debug-print overly long data URLs · 97eb1de1
      Igor Kushnir authored
      When QWebEnginePage::setHtml() is called, the URL's string
      representation becomes "data:text/html;charset=UTF-8,PAGE", where PAGE
      stands for the entire HTML contents. If kdevplatform.documentation.debug
      is true, KDevelop prints a very long line each time a CMake or Man
      documentation page is loaded. Such long lines are not particularly
      useful but can slow the application down.
      
      Print a general message in place of a URL with the "data" scheme.
      97eb1de1
  8. 13 Jul, 2022 1 commit
  9. 12 Jul, 2022 2 commits
  10. 11 Jul, 2022 3 commits
  11. 10 Jul, 2022 9 commits