[cfe-dev] Threading and Clang

Martin C. Martin mmartin at Endeca.com
Mon Sep 13 14:20:26 PDT 2010


Hi,

 

We're considering using Clang as a just in time compiler.  It works
great in a single thread, but we can't get it working from multiple
threads.

 

Here's one attempt, where we create a single execution engine used by
all threads, and one compiler instance per thread.  The result is
corruption and a core dump.  We've also tried giving each thread its own
execution engine, still no dice.  This is with Clang/LLVM 2.7 on Ubuntu
9.10.

 

I've also attached a self contained zip file with the exact compile line
and code that reproduces the problem.

 

Any idea what we're doing wrong?

 

Thanks,

Martin

 

Here's an example stack trace:

 

*** glibc detected *** ./boom: double free or corruption (fasttop):
0x00007fb9b421c9b0 ***

======= Backtrace: =========

/lib/libc.so.6[0x7fbabcf352f6]

/lib/libc.so.6(cfree+0x6c)[0x7fbabcf39c6c]

./boom(llvm::AttributeListImpl::DropRef()+0x3e)[0x18b4a4c]

./boom(llvm::AttrListPtr::operator=(llvm::AttrListPtr
const&)+0x45)[0x18b3953]

./boom(llvm::Function::setAttributes(llvm::AttrListPtr
const&)+0x24)[0xec2e1c]

./boom(llvm::Function::addAttribute(unsigned int, unsigned
int)+0x5d)[0x19101e5]

./boom(llvm::Argument::addAttr(unsigned int)+0x32)[0x191094a]

./boom((anonymous
namespace)::FunctionAttrs::AddNoCaptureAttrs(std::vector<llvm::CallGraph
Node*, std::allocator<llvm::CallGraphNode*> > const&)+0x131)[0x12e3f05]

./boom((anonymous
namespace)::FunctionAttrs::runOnSCC(std::vector<llvm::CallGraphNode*,
std::allocator<llvm::CallGraphNode*> >&)+0x32)[0x12e464e]

./boom((anonymous namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*,
std::vector<llvm::CallGraphNode*, std::allocator<llvm::CallGraphNode*>
>&, llvm::CallGraph&, bool&)+0xa8)[0x17fafb4]

./boom((anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)+0x24e)[0x17fb418]

./boom(llvm::MPPassManager::runOnModule(llvm::Module&)+0x17e)[0x194930c]

./boom(llvm::PassManagerImpl::run(llvm::Module&)+0x6f)[0x194b0b1]

./boom(llvm::PassManager::run(llvm::Module&)+0x21)[0x194b113]

./boom((anonymous
namespace)::BackendConsumer::EmitAssembly()+0x241)[0xdfc3f9]

./boom((anonymous
namespace)::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)+0
x91)[0xdffcef]

./boom(clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*,
clang::ASTContext&, bool, bool,
clang::CodeCompleteConsumer*)+0x2a4)[0xfc7164]

./boom(clang::ASTFrontendAction::ExecuteAction()+0x100)[0xe177a2]

./boom(clang::FrontendAction::Execute()+0xe2)[0xe17892]

./boom(clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)+0x
2a3)[0xe01427]

./boom(go(void*)+0x25f)[0xdf64f3]

/lib/libpthread.so.0[0x7fbabd9e0a04]

/lib/libc.so.6(clone+0x6d)[0x7fbabcf9ed4d]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100913/52295cf5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cpp
Type: application/octet-stream
Size: 3366 bytes
Desc: test.cpp
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100913/52295cf5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boom.tgz
Type: application/x-compressed
Size: 5058 bytes
Desc: boom.tgz
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100913/52295cf5/attachment.bin>


More information about the cfe-dev mailing list