[osg-users] Multithreading crash due to osgDb::Registry::instance()

Robert Osfield robert.osfield at gmail.com
Tue Mar 17 02:06:51 PDT 2009

Hi Anthony,

I have avoided adding a mutex into the Registry::instance() method as it
would incur a cost for every call to it, and it's only the very first call
that it's an issue for so it's the only time you need to be careful about
access to it.

Given I don't want to introduce a mutex one then has to make sure the
instance() method is called up front in your app, and most OSG applications
will call it during the single thread init of the app, and in your case
you'll just need to call it explictly.   An alternative might be to have a
proxy class call the instance() method, or perhaps just have the viewer
constructor call instance() just in case.


On Tue, Mar 17, 2009 at 6:25 AM, I-Nixon, Anthony D <
anthony.d.nixon at boeing.com> wrote:

> I've encountered a crash when using CompositeViewer in Multithreaded
> mode due to concurrent access to osgDb::Registry::instance().
> The usage scenario is having two views (that have an empty scene graph -
> since no data has been loaded, osgdb::Registry::instance() hasn't yet
> been called).
> On the first frame, each of the render threads calls
> osgDb::Registry::instance(), and one gets back a null pointer (which is
> kind of bad for an instance :-)
> The fix for me is easy - just call osgDb::Registry::instance() sometime
> before starting rendering, but a more general solution would be better,
> of course.
> This is with OSG 2.8.0 - although there don't appear to have been any
> changes in this area in the trunk, either.
> I've only confirmed this on Windows XP and Visual C++ 8.
> Anthony Nixon
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090317/0d98d266/attachment-0003.htm>

More information about the osg-users mailing list