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.
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)