Since Tcl uses Apartment Threading Model as its fundamental multithreading frame, every tcl interpreter obj is bound to the thread that creates it. In my program, each thread invokes Tcl_CreateInterp to create its own interpreter the first time it needs to invoke any tcl commands. But the Q&A test reported that valgrind (v3.13.0) complains possible data race issue when threads intend to create their own interpreter. The data race happens at apis Tcl_NewStringObj/TEBCresume/TclNREvalObjv, etc. Anything to correct for my use model? Or is it false positive of valgrind?
I use boost::thread_specific_ptr to manage the thread local interpreter.
Tcl_Interp* GetThreadInterp()
{
static boost::thread_specific_ptr < Tcl_Interp > tcl_interp;
if (!tcl_interp.get())
tcl_interp.reset(Tcl_CreateInterp());
return tcl_interp.get();
}