Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-21559

Clangbackend: heap-use-after-free when doing completion/reparsing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • None
    • Qt Creator 4.8.0-rc1
    • C/C++/Obj-C++ Support
    • None
    • a9dd0e71768c7e18b3aa401fdba00334719b104f (clang/clang/release_70-based)

      I can reproduce the heap-use-after-free, but not very reliably as it depends on timing (thus your machine, the code to process, ...).

      What works here is:

      1. Open tests/unit/unit.pro
      2. Open clangcodemodelserver-test.cpp
      3. Apply
       diff --git a/tests/unit/unittest/clangcodemodelserver-test.cpp b/tests/unit/unittest/clangcodemodelserver-test.cpp
      index c74e2a96d8..38f571e69b 100644
      --- a/tests/unit/unittest/clangcodemodelserver-test.cpp
      +++ b/tests/unit/unittest/clangcodemodelserver-test.cpp
      @@ -44,6 +44,7 @@
       
       #include <QCoreApplication>
       #include <QFile>
      +#include <QTemporaryDir>
       
       using testing::Property;
       using testing::Contains;
      @@ -189,6 +190,9 @@ TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletion)
       
           expectCompletionFromFileA();
           requestCompletionsInFileA();
      +
      +    QTemporaryDir dir;
      +    ASSERT_TRUE(dir.isValid();
       }
       
       TEST_F(ClangCodeModelServerSlowTest, RequestAnnotations)
      1. Then remove and type the added "ASSERT_TRUE(", sometimes it's enough to remove and add "(". Vary the speed when doing so.

       

      Sometimes "corrupted double-linked list" appears in the output.

      Sometimes the clangbackend process does not react to anything. In this case an attached debugger shows that it tries to print some stacktrace but somehow deadlocks or so.

      Note that reverting

      helps - at least I do not see the heap-use-after-free with the address sanitizer build.

        1. clangbackend_1.txt
          32 kB
          Nikolai Kosjar
        2. clangbackend_asan_2.txt
          25 kB
          Nikolai Kosjar
        3. clangbackend_asan_3.txt
          25 kB
          Nikolai Kosjar
        4. clangbackend_asan_4.txt
          15 kB
          Nikolai Kosjar
        5. clangbackend_asan_5.txt
          27 kB
          Nikolai Kosjar
        6. clangbackend_asan_6.txt
          15 kB
          Nikolai Kosjar
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            yvvan Ivan Donchevskii
            kosjar Nikolai Kosjar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes