[cfe-dev] Memory Leaks in CommonOptionsParser
Uri Mann
umann at symantec.com
Sun Mar 8 00:33:41 PST 2015
I'm new to reporting issues with LLVM/CLANG and I'm wondering if someone can guide me. Using version 3.5.0 I discovered a memory leak from global objects used by the command line parsing framework. Typically this is not visible unless you have clang code combined with boost which turns heap debugging on very early. This bug is causing the unit tests to fail because of the memory leaks discovered by the MSVC runtime.
The flowing short program will help reproduce this issue:
#include <clang/Tooling/CommonOptionsParser.h>
#if defined(_DEBUG)
# include <crtdbg.h>
// Turn on allocation debugging before global variables are initialized. This will help catch
// memory leaks from global objects
static int __ = ::_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
#endif // _DEBUG
llvm::cl::OptionCategory CP3Category("test");
int main(int argc, const char **argv) {
return 0;
}
When compiled for debug with MSVC it produce the following output:
The thread 0xf1d8 has exited with code 0 (0x0).
Detected memory leaks!
Dumping objects ->
{165} normal block at 0x00368930, 16 bytes long.
Data: < T 0 > A8 C1 8E 1C 00 00 00 00 54 B3 30 1D CC CC CC CC
{162} normal block at 0x003687C8, 84 bytes long.
Data: < 6 6 > DC 87 36 00 DC 87 36 00 10 00 00 00 02 00 00 00
Object dump complete.
The program '[71088] main.exe' has exited with code 0 (0x0).
Thanks in advance.
-Uri Mann
More information about the cfe-dev
mailing list