Jeffrey Yasskin
2010-Mar-19 06:02 UTC
[LLVMdev] Checker for destruction-needing classes allocated in BumpPtrAllocators?
Hi Ted, Doug said you might have a clang-based checker that would detect when people allocate memory with a BumpPtrAllocator and then construct a class into it that needs destruction. In killing valgrind-found memory leaks in LLVM, I've found several instances of this mistake. They often involve SmallVectors, which only show up as leaks in valgrind if they happen to overflow their static allocation, so it would be useful to also check this statically. Could you point me to any code you have for this? Thanks, Jeffrey
Ted Kremenek
2010-Mar-19 19:59 UTC
[LLVMdev] Checker for destruction-needing classes allocated in BumpPtrAllocators?
Hi Jeffrey, The check in question checks that specific LLVM classes (and their subclasses) don't have fields that are SmallVector or std::vector. It's basically a policy check on those classes; it doesn't know anything about BumpPtrAllocator itself. The code for the check is located here: llvm/tools/clang/lib/Checker/LLVMConventionsChecker.cpp It can be run on the LLVM codebase using scan-build: http://clang-analyzer.llvm.org/scan-build.html When analyzing C++ code, you will need to: (1) Define the environment variable CCC_ANALYZER_CPLUSPLUS to enable C++ analysis (I didn't want casual users trying it yet) (2) Run scan-build with the -analyzer-check-llvm-conventions option. For example: $ export CCC_ANALYZER_CPLUSPLUS=1 $ scan-build <path/to/llvm/source>/configure $ scan-build -analyzer-check-llvm-conventions -V make Ted On Mar 18, 2010, at 11:02 PM, Jeffrey Yasskin wrote:> Hi Ted, > > Doug said you might have a clang-based checker that would detect when > people allocate memory with a BumpPtrAllocator and then construct a > class into it that needs destruction. In killing valgrind-found memory > leaks in LLVM, I've found several instances of this mistake. They > often involve SmallVectors, which only show up as leaks in valgrind if > they happen to overflow their static allocation, so it would be useful > to also check this statically. Could you point me to any code you have > for this? > > Thanks, > Jeffrey
Maybe Matching Threads
- [LLVMdev] Static destructor problem with recent HEAD
- [LLVMdev] Static destructor problem with recent HEAD
- [LLVMdev] RFC: Reduce the memory footprint of DIEs (and DIEValues)
- [LLVMdev] Static destructor problem with recent HEAD
- Identifying objects within BumpPtrAllocator.