Hi Daniel, Thanks for the bug report/characterization. I haven't looked at the code yet, but your suggestion of checking return values sounds reasonable, and would suggest falling back to single threaded when this happens.
I suspect when hitting memory limits you'll start to see other problems as well so the single threaded fallback is likely only a solution for the deadlocks. Could you have a bash at making modifications to ViewBase::startThreading() to see if using a SingleThreaded fallback works? If so then I can merge this change. Robert. On 22 March 2013 10:43, Daniel Schmid <[email protected]> wrote: > Hi Robert > > I discovered an issue with multithreading. Consider the following Code in > ViewerBase::startThreading: > > > Code: > > void ViewerBase::startThreading() > { > .... > > if (_threadingModel==CullThreadPerCameraDrawThreadPerContext && > numThreadsOnStartBarrier>1) > { > Cameras::iterator camItr; > > .... > > for(camItr = cameras.begin(); > camItr != cameras.end(); > ++camItr) > { > osg::Camera* camera = *camItr; > if (camera->getCameraThread() && > !camera->getCameraThread()->isRunning()) > { > OSG_INFO<<" camera->getCameraThread()-> > "<<camera->getCameraThread()<<std::endl; > [b] camera->getCameraThread()->startThread();[/b] > } > } > } > > .... > > for(citr = contexts.begin(); > citr != contexts.end(); > ++citr) > { > osg::GraphicsContext* gc = (*citr); > if (gc->getGraphicsThread() && !gc->getGraphicsThread()->isRunning()) > { > OSG_INFO<<" gc->getGraphicsThread()->startThread() > "<<gc->getGraphicsThread()<<std::endl; > [b]gc->getGraphicsThread()->startThread();[/b] > // OpenThreads::Thread::YieldCurrentThread(); > } > } > > _threadsRunning = true; > > OSG_INFO<<"Set up threading"<<std::endl; > } > > > > > > We suppose that each call to startThread actually starts the tread. When the > call returns the thread is actually running. > BUT: there are cases where for some reason the thread was not able to start. > We had such a issue where our 32-bit process was running on 3GB memory limit > and the thread was refused !! There might be other cases , errno is your > friend in telling you what was the reason (so was for me). > > Actually Thread::startThread returns an int which is non-zero for such cases. > You should update the startThreading method to react accordingly when such an > error case occures. Otherwise OSG assumes that threads are running, but > nothing is happening and some thread sync wait calls end up dead-locked! > > > Regards > Daniel > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=53204#53204 > > > > > > _______________________________________________ > 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

