Ok, it looks like the thread "sort of" dies when we leave the scope of
main. When I get to the atexit() callback, The only thread left is
Main Thread (running main()).
All other threads are not running any more (according to VisualStudio
and Task Manager).

However, querying the threads for isRunning() returns true.


This code works just fine inside the scope of main.
Its only if I keep threads alive during leaving main() I get the problems.
It seems that I HAVE to kill all threads before end of main.

Anyone had this problem before?


On Thu, May 15, 2008 at 12:08 PM, Robert Osfield
<[EMAIL PROTECTED]> wrote:
> Hi Anders,
>
>  When managing threads one has to be very careful about destruction
>  order.  The key is to make sure the the threads are stopped before any
>  objects they are operating on are deleted.  Since you are off in your
>  own code that isn't much specifically that I and others can do to
>  help.
>
>  Robert.
>
>
>
>  On Thu, May 15, 2008 at 10:11 AM, Anders Backman <[EMAIL PROTECTED]> wrote:
>  > Long time no see :-)
>  >
>  > Using Osg 2.2.0.
>  > WinXP, VisualStudio 2008.
>  >
>  >
>  > I have a slight problem that I cant seem to get around.
>  > We have a thread with a few OpenThread::Block, and in the destructor
>  > of the thread we call block.release().
>  >
>  > The thing is that the thread is still running when scope of main goes
>  > out. So we have a atexit() function that does the deallocation, and
>  > tries to delete the threads.
>  > The problem is that one of the Blocks (we have two in the thread)
>  > causes a hang in the call to: Condition::cooperativeWait().
>  >
>  > This was mentioned as a problem here:
>  >
>  > 
> http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2008-March/009081.html
>  >
>  > With no result as far as I can see...
>  >
>  > Its a problem only under win32. I have seen it before, but at that
>  > time we found a way around it (by shutting down the threads in main),
>  > this time we don't.
>  >
>  > Callstack:
>  >
>  >        
> ot9-OpenThreadsd.dll!OpenThreads::Win32ConditionPrivateData::broadcast()
>  >  Line 71        C++
>  >        ot9-OpenThreadsd.dll!OpenThreads::Condition::broadcast()  Line 100  
>     C++
>  >        agxd.dll!OpenThreads::Block::release()  Line 69 + 0x13 bytes    C++
>  >        agxd.dll!agx::Block::release()  Line 540        C++
>  >        agxd.dll!agx::WorkThread::~WorkThread()  Line 33        C++
>  >        agxd.dll!agx::WorkThread::`vector deleting destructor'()  + 0x54 
> bytes  C++
>  >        agxd.dll!agx::ThreadPool::shutdown()  Line 106 + 0x2c bytes     C++
>  >
>  >
>  >
>  > So anyone seen this (and solved it) or any ideas of what might be
>  > behind this issue?
>  >
>  >
>  > --
>  >
>  >
>  > ________________________________________________________________
>  >  Anders Backman Email: [EMAIL PROTECTED]
>  >  HPC2N/VRlab Phone: +46 (0)90-786 9936
>  >  Umea university Cellular: +46 (0)70-392 64 67
>  >  S-901 87 UMEA SWEDEN Fax: +46 90-786 6126
>  >  http://www.cs.umu.se/~andersb
>  > _______________________________________________
>  > osg-users mailing list
>  > osg-users@lists.openscenegraph.org
>  > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>  >
>  _______________________________________________
>  osg-users mailing list
>  osg-users@lists.openscenegraph.org
>  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 


________________________________________________________________
 Anders Backman Email: [EMAIL PROTECTED]
 HPC2N/VRlab Phone: +46 (0)90-786 9936
 Umea university Cellular: +46 (0)70-392 64 67
 S-901 87 UMEA SWEDEN Fax: +46 90-786 6126
 http://www.cs.umu.se/~andersb
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to