Valgrind memcheck errors in llvm

I have ran under valgrind memcheck the process using libLLVM-2.9.so (rev.126022) and got several errors:

==24227== Invalid read of size 1
==24227== at 0x40274C9: memcpy (mc_replace_strmem.c:497)
==24227== by 0x40D5B84: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/libstdc++.so.6.0.14)
==24227== by 0x40D5C50: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.14)
==24227== by 0x97074CE: llvm::StringRef::str() const (StringRef.h:159)
==24227== by 0x970750E: llvm::StringRef::operator std::string() const (StringRef.h:176)
==24227== by 0x9D22519: llvm::Module::Module(llvm::StringRef, llvm::LLVMContext&) (Module.cpp:61)
==24227== by 0x99FCD1D: llvm::getLazyBitcodeModule(llvm::MemoryBuffer*, llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:2641)
==24227== by 0x99FCDF8: llvm::ParseBitcodeFile(llvm::MemoryBuffer*, llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:2660)

==24227== Mismatched free() / delete / delete []
==24227== at 0x40257ED: free (vg_replace_malloc.c:366)
==24227== by 0x9D765EF: llvm::ExecutionEngine::~ExecutionEngine() (ExecutionEngine.cpp:74)
==24227== by 0x9E5F56A: llvm::JIT::~JIT() (JIT.cpp:347)
==24227== by 0x9E5F5A6: llvm::JIT::~JIT() (JIT.cpp:355)

==24227== Invalid read of size 1
==24227== at 0x4026CBC: strlen (mc_replace_strmem.c:282)
==24227== by 0x96EA852: llvm::StringRef::StringRef(char const*) (StringRef.h:59)
==24227== by 0x99FCCF0: llvm::getLazyBitcodeModule(llvm::MemoryBuffer*, llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:2641)
==24227== by 0x99FCDF8: llvm::ParseBitcodeFile(llvm::MemoryBuffer*, llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:2660)

==24227== Mismatched free() / delete / delete []
==24227== at 0x4025504: operator delete(void*) (vg_replace_malloc.c:387)
==24227== by 0x9C69C09: llvm::BasicBlock::~BasicBlock() (BasicBlock.cpp:83)
==24227== by 0x9C6B509: llvm::ilist_node_traits<llvm::BasicBlock>::deleteNode(llvm::BasicBlock*) (in /usr/local/llvm/svn-r126022.dbg/lib/libLLVM-2.9svn.so)
==24227== by 0x9C6B103: llvm::iplist<llvm::BasicBlock, llvm::ilist_traits<llvm::BasicBlock> >::erase(llvm::ilist_iterator<llvm::BasicBlock>) (ilist.h:463)
==24227== by 0x9C69D1E: llvm::BasicBlock::eraseFromParent() (BasicBlock.cpp:101)
==24227== by 0x9CB6940: llvm::Function::dropAllReferences() (Function.cpp:233)
==24227== by 0x9D23754: llvm::Module::dropAllReferences() (Module.cpp:449)
==24227== by 0x9D225E9: llvm::Module::~Module() (Module.cpp:70)

Wow.

I remember seeing similar valgrind errors since at least 2.7 or so,
Perhaps its time for a second look?

-jason

Hi Yuri,

I have ran under valgrind memcheck the process using libLLVM-2.9.so
(rev.126022) and got several errors:

how to reproduce this? What commands did you run exactly?

Ciao, Duncan.