[LLVMdev] clang::CompilerInstance leaks memory on compilation failures

ajay gopalakrishnan
Sat, 23 May 2015 20:50:46 -0000

Hi,

I am using the clang::CompilerInstance to compile a piece of code. I am
running my tests through Clang -fsanitize=address.
The test case where the compilation succeeds does not leak any memory. But
if the compilation fails, then it seems to leak memory.

Is this a known bug?

Am I supposed to explicitly freeup somethings when the compilation fails
(The code already calls llvm::shut_down() towards the end of the process)

if(!clang.ExecuteAction(*action)) { throw new CompilationError("failed to
compile", std::move(errors)); }

The rest of the code looks similar to what others have posted on the
internet (but haven't gotten a response yet):
http://stackoverflow.com/questions/24314060/clang-in-memory-parser-does-not-perform-full-clean-up-for-the-memory-it-allocate
http://clang-developers.42468.n3.nabble.com/Running-multiple-actions-with-clang-interpreter-without-memory-leak-td3451862.html

I am using Clang3.5

Thanks!
Ajay
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20150523/ddade608/attachment.html>