[osg-users] deadlock in independent contexts

Raphael Sebbe raphael.sebbe at gmail.com
Thu Jul 31 02:45:05 PDT 2008


Hi,

I have some additional information.
I moved to OSGv2.6rc1, built the .dylib with cmake. I still get the same
deadlock situation, with the same thread backtraces (I had to create 7
windows, the log makes it more difficult to get to that situation).

I uncommented this line in getCompileContext:
osg::notify(osg::NOTICE)<<"GraphicsContext::getCompileContext
"<<contextID<<std::endl;

And it shows this (meaning all threads except one, "0",  are blocked):
.....

*GraphicsContext::getCompileContext 3*

*GraphicsContext::getCompileContext 5*

*GraphicsContext::getCompileContext 6*

*GraphicsContext::getCompileContext 1*

*GraphicsContext::getCompileContext 3*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 4*

*GraphicsContext::getCompileContext 2*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

*GraphicsContext::getCompileContext 0*

... always 0


Can it be an OpenThreads implementation problem? Do you have any other
suggestion?

Note: made on a dual proc system (Core2Duo), compiled in 32-bit.

Thank you,

Raphael



On Tue, Jul 29, 2008 at 5:26 PM, Raphael Sebbe <raphael.sebbe at gmail.com>wrote:

> Hi,
> I have come across a problem when performing multi-threaded rendering.
>
> The application setup is as follows: 4 windows with 4 independent OpenGL
> contexts, with 4 associated GraphicsWindowEmbedded. There are 4 threads,
> invoking Viewer->frame().
>
> After some time, 3 out of 4 threads are blocked, using gdb, I get the
> deadlock locations:
>
> 2 threads are in this:
>
> #0 0x90c5a4ee in semaphore_wait_signal_trap
> #1 0x90c61fc5 in pthread_mutex_lock
> #2 0x00299ffc in std::_Rb_tree<unsigned int, std::pair<unsigned int const,
> ContextData>, std::_Select1st<std::pair<unsigned int const, ContextData> >,
> std::less<unsigned int>, std::allocator<std::pair<unsigned int const,
> ContextData> > >::insert_unique
> #3 0x00295b18 in osg::GraphicsContext::getCompileContext
> #4 0x0051ed05 in osgViewer::Renderer::cull_draw
> #5 0x00297350 in osg::GraphicsContext::runOperations
> #6 0x00521d20 in osgViewer::ViewerBase::renderingTraversals
> #7 0x00003b91 in -[OSGView drawRect:] at OSGView.mm:367
> #8 0x00003d7d in -[OSGView displayFrame:] at OSGView.mm:400
> #9 0x00003007 in MEDisplayLinkCallback at OSGView.mm:102
> #10 0x955a8013 in CVDisplayLink::performIO
> #11 0x955a863f in CVDisplayLink::runIOThread
> #12 0x90c8b6f5 in _pthread_start
> #13 0x90c8b5b2 in thread_start
>
>
> Another one in this:
>
> #0 0x90c5a4ee in semaphore_wait_signal_trap
> #1 0x90c61fc5 in pthread_mutex_lock
> #2 0x00299ffc in std::_Rb_tree<unsigned int, std::pair<unsigned int const,
> ContextData>, std::_Select1st<std::pair<unsigned int const, ContextData> >,
> std::less<unsigned int>, std::allocator<std::pair<unsigned int const,
> ContextData> > >::insert_unique
> #3 0x00295b18 in osg::GraphicsContext::getCompileContext
> #4 0x00060060 in osgDB::DatabasePager::requiresExternalCompileGLObjects
> #5 0x0051ef88 in osgViewer::Renderer::cull_draw
> #6 0x00297350 in osg::GraphicsContext::runOperations
> #7 0x00521d20 in osgViewer::ViewerBase::renderingTraversals
> #8 0x00003b91 in -[OSGView drawRect:] at OSGView.mm:367
> #9 0x00003d7d in -[OSGView displayFrame:] at OSGView.mm:400
> #10 0x00003007 in MEDisplayLinkCallback at OSGView.mm:102
> #11 0x955a8013 in CVDisplayLink::performIO
> #12 0x955a863f in CVDisplayLink::runIOThread
> #13 0x90c8b6f5 in _pthread_start
> #14 0x90c8b5b2 in thread_start
>
> Seems to be in there:
> GraphicsContext* GraphicsContext::getCompileContext(unsigned int contextID)
> {
>     // osg::notify(osg::NOTICE)<<"GraphicsContext::getCompileContext
> "<<contextID<<std::endl;
>     OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_contextIDMapMutex);
>     ContextIDMap::iterator itr = s_contextIDMap.find(contextID);
>     if (itr != s_contextIDMap.end()) return
> itr->second._compileContext.get();
>     else return 0;
> }
>
>
> I did not configure any thread specific flags in OSG (perhaps I should have
> done that?), I am not familiar with how OSG handles threading.
> I also cannot instrument OSG to debug this as I am using precompiled
> binaries (OSX frameworks), OSG 2.2.0-10.5SDK.
>
> I can workaround this by making all rendering mutually exclusive, but this
> is obviously not what I want.
>
> Any advice would be greatly appreciated. Thanks,
>
> Raphael
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080731/bb3bdf21/attachment-0003.htm>


More information about the osg-users mailing list