[LLVMbugs] [Bug 19690] New: clang_codeCompleteGetDiagnostic() leaks memory when called

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 8 11:58:22 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19690

            Bug ID: 19690
           Summary: clang_codeCompleteGetDiagnostic() leaks memory when
                    called
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

r144269 changed clang_disposeDiagnostic() to be a no-op and changed how
diagnostics are stored.

However, code completion diagnostics returned by
clang_codeCompleteGetDiagnostic() are still allocated and expect
clang_disposeDiagnostic() to clean them up – now this no longer happens.


The fix is probably to let the completion context lazily own all completion
diagnostics, just like r144269 did for regular diagnostics.



Example LSan report:

Script:
--
/usr/local/google/ssd/asan-boot/stage2/./bin/c-index-test
-code-completion-at=/home/kcc/llvm/tools/clang/test/Index/complete-enums.c:11:1
/home/kcc/llvm/tools/clang/test/Index/complete-enums.c |
/usr/local/google/ssd/asan-boot/stage2/./bin/FileCheck -check-prefix=CHECK-CC1
/home/kcc/llvm/tools/clang/test/Index/complete-enums.c
/usr/local/google/ssd/asan-boot/stage2/./bin/c-index-test
-code-completion-at=/home/kcc/llvm/tools/clang/test/Index/complete-enums.c:12:8
/home/kcc/llvm/tools/clang/test/Index/complete-enums.c |
/usr/local/google/ssd/asan-boot/stage2/./bin/FileCheck -check-prefix=CHECK-CC2
/home/kcc/llvm/tools/clang/test/Index/complete-enums.c
--
Exit Code: 1

Command Output (stderr):
--
/home/kcc/llvm/tools/clang/test/Index/complete-enums.c:10:13: warning: 'Color'
is deprecated [-Wdeprecated-declarations]
Number FIX-ITs = 0
/home/kcc/llvm/tools/clang/test/Index/complete-enums.c:4:34: note: 'Color' has
been explicitly marked deprecated here
Number FIX-ITs = 0

=================================================================
==15956==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 144 byte(s) in 2 object(s) allocated from:
    #0 0x4952e0 in operator new(unsigned long)
/home/kcc/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:62
    #1 0x7f5e06bf1351 in clang_codeCompleteGetDiagnostic
/home/kcc/llvm/tools/clang/tools/libclang/CIndexCodeCompletion.cpp:872
    #2 0x4b63c8 in perform_code_completion
/home/kcc/llvm/tools/clang/tools/c-index-test/c-index-test.c:2073
    #3 0x4b938b in cindextest_main
/home/kcc/llvm/tools/clang/tools/c-index-test/c-index-test.c:4005
    #4 0x4be537 in thread_runner
/home/kcc/llvm/tools/clang/tools/c-index-test/c-index-test.c:4104
    #5 0x7f5e0847c78f in ExecuteOnThread_Dispatch(void*)
/home/kcc/llvm/lib/Support/Threading.cpp:75
    #6 0x7f5e05923e99 in start_thread
/build/buildd/eglibc-2.15/nptl/pthread_create.c:308

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140508/d03b6a67/attachment.html>


More information about the llvm-bugs mailing list