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

Robert Osfield robert.osfield at gmail.com
Thu Sep 20 01:54:00 PDT 2007

Hi Adam,

On 9/20/07, Adam Coates <acoates at stanford.edu> wrote:
> So, I just realized that the OSG folks are not synonymous with the
> OpenThreads folks.  ^_^  Sorry for dropping this on the wrong list
> then.

Well OpenThreads list is a flat line, almost  all (99.9%) OpenThreads
activity and development is done by members of the OpenSceneGraph
community.  So this is probably the best place to raise issues like
this.  Responsibility for maintaining OpenThreads has also fallen on
my shoulders as it effectively became an orphaned project when the
original project lead got sucked into non coding management.

>In that light, it may not even be considered a bug in OT,
> since, theoretically, it might be unfair to call the Thread destructor
> while the thread is running (even though I'm pretty sure they intended
> isRunning() to work as we'd expect).

Well this type of usage is kinda abusing the Thread class, but I'd
still say this way a bug.

> It should be possible to add a workaround in the following way:
> 1.  Before starting the thread, set a flag to indicate that the thread
> is "starting up".
> 2.  Have the thread's run() routine unset this flag.
> Before deleting the Thread, make sure that both the "starting up" flag
> and the isRunning flag are false.  One of these will have to be true
> if the thread has not reached the run() method yet, or has not
> completely exited from run() -- thus avoiding the problem.

I'll have ponder in this issue, I'm more inclined to use a mutex in
some way that just a straight flag.

> My question:  does somebody want me to implement this workaround and
> submit it to you?  Alternatively, I can just point out the break to
> the OpenThreads people and we can wait for a patch...

It's best to just roll your sleeves up and get stuck in.  First up we
need a test that can reliably reproduce the error.  Would the
following code block do the trick?

       OpenThreads::Thread thread;


More information about the osg-users mailing list