Problems with parallelizing lli

Hi,
I am trying to parallize the lli interpreter (code: http://pastebin.com/6iuHNH3Q). I am using ubuntu 12.04 with llvm
version 3.1. Each thread uses a seperate LLVMContext, however the
interpreter continues to crash.

$ clang -S -emit-llvm test.c && parallel_lli test.s
Error msg: …/include/llvm/Support/Mutex.h:116:
bool llvm::sys::SmartMutex::release(): Assertion `((recursive &&
acquired) || (acquired == 1)) && “Lock not acquired before release!”’ failed."")))

What am I doing wrong?

Thank you.

Diff to original tools/lli/lli.cpp and test.c (simple hello world) attached.

lli.diff (3.2 KB)

test.c (98 Bytes)