Problems with parallelizing lli

I am trying to parallize the lli interpreter (code: I am using ubuntu 12.04 with llvm
version 3.1. Each thread uses a seperate LLVMContext, however the
interpreter continues to crash.
Error msg: ..../include/llvm/Support/Mutex.h:116:
bool llvm::sys::SmartMutex<true>::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 attached.

lli.diff (3.2 KB)