[osg-users] OpenThreads threading bug on creation/deletion (leads to crashes)

Robert Osfield robert.osfield at gmail.com
Tue Sep 25 00:26:57 PDT 2007

Hi Adam,

On 9/24/07, Adam Coates <acoates at stanford.edu> wrote:
> It looks like there's still a problem with the current setup.  The
> Thread object itself can get deleted before the pthread actually gets
> to the lock (which, I guess is what you just added).

If I understand correctly you are saying that the Thread object is
being deleted before the static StartThread function gets called.   In
this case its rather an awkward problem to solve.  Perhaps one could
have lock made in the Thread::startThread method that is unlocked by
the static StartThread function once it's complete.

> While it looks
> like this doesn't cause a crash, the problem is evidenced by valgrind
> (reports uninitalized memory reads/writes to the lock -- which got
> freed by the Thread destructor).
> You seem like you're pretty busy, so if you want, I can take a crack
> at this -- I think the Thread code is simple enough, but I'll need to
> think a bit to figure out how to get around this.  One (simple)
> solution is to just join() the thread from the ~Thread() destructor.

I expect the valgrind warnings are unrelated to this start problem.


More information about the osg-users mailing list