Hi Anders,

I haven't tested out the app yet, but my first thought is that perhaps
the clean up on exit is destroying the thread objects + implementation
prior to the singleton destructor cleaning up.  I have seen a number
of issues like this over the years, and one just has to be careful
about what gets destructed when to make sure the runtime has all the
parts it needs to clean up correctly.  This clean up issue doesn't
require a bug in OpenThreads/Win32 threads for it occur, it can occur
simply due to destruction order.

Have you tested you test app out on any other platforms?

Robert.

On Thu, Dec 2, 2010 at 9:06 PM, Anders Backman <[email protected]> wrote:
> Hi all.
> Im using OpenSceneGraph 2.8.3 under windows. Visual studio 2008.
> However, this problem has been around for at least 2 years, so it existed in
> previous versions too.
> I have finally after two years? isolated the bug I reported quite a while
> back: http://lists.openscenegraph.org/htdig.cgi/osg-users-openscenegraph.org/2008-May/011360.html
> I took a deep breath, and after quite a few hours I managed to isolate the
> problem into one .dll file and one .exe file.
> The problem:
> Assume I have an application, it creates a thread.
> For various reason, I want to register this thread to a function for later
> destruction (in our lib we give the pointer of the thread to a singleton
> which later destroys the thread). In this example, its just registers a
> function in atexit() which will delete the thread.
> Notice that this call to atexit() is done within ANOTHER DLL (otbugdll.cpp).
> When the app exits, the atexit() is called and the thread is destroyed. But
> the problem is that it hangs at the call to m_block.release() in the
> destructor.
> If I instead call atexit() from the main app, everything works just fine.
> This means, that the call to delete for the thread is the same, its just
> initiated from an atexit() call done from main().
>
> What this does, is that we need to have a call:
> ThreadPool::instance()->shutdown();
> that HAVE to be called BEFORE the end of the scope of main. Really
> irritating.
> We cant use atexit() from within the library (because it is done from a
> separate lib/dll, which regenerates the problem).
>
> To build this, you need to set the OSG_DIR path to your OpenSceneGraph
> install, run cmake on it, and build the project.
> If SHOULD_HANG is defined it will...hang.
> http://www8.cs.umu.se/~andersb/otbug.zip
>
>
> I have done just about everything I can come up with to try to resolve this
> problem, but nothing works.
> I have tried to use a DllMain() function, which catches the events for
> attaching and detaching the dll, and doing the delete of the thread there. I
> have tried every combination of singletons, static variables etc, but it all
> fails.
> So the above example is not really exactly my original problem, but it
> reproduces the problem quite nicely. I cannot really see what the problem
> is.
> The flow of code is exactly the same no matter if SHOULD_HANG is defined or
> not.
> It might be a bug in how OpenThreads use the win32 threading API.
> OR it might be a limitation of the Win32 threading API.
> Thankful for any help on this matter.
> It has been on my mind now for more two years.
> /Anders
> --
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to