Hi All,

Yesterday I recieved a bug report, example that successful recreated
the crash and a fix.  This morning I investigated the issue further
adding to osgunittests and new part accessible via "osgunittests
thread", and have also checked a fix to osg::notify() based on the
proposed fix - osgunittests thread crashed before applying this fix,
and now no longer crashes ;-)

So what is this "ex" problem all about?  It turns out that
osg::notify() use of a single std::ofstream("/dev/null") for silently
discarding notify output was not thread safe.  Use of std::endl in
notify statements made the bug far more difficult to reproduce, but
when just using "\n" for line endings as the unit test does a crash
comes about almost immediately when running multi-threaded.  The test
itself really thrashes osg::notify and hence the ofstream("/dev/null")
as each of the tests does nothing else other than output to
osg::notify() so is able to create a crash almost immediately (with
the old code).

In a real-world OSG app we'll not have such a stiff test, so the
problem would have been largely unnoticed - the chances of hitting the
threading issue being pretty low - but still real.  The group who
tracked this issue down's app for instance would crash very
occassionally, the problem being traced back to osg::notify()'s use of
std::ofstream("/dev/null").  This very occasional crash is something
others users might have come across too, but never pinpointed - the
type of problem that could easily bite you once you've deployed and be
hard to track down.

The fix to this bug has been to implement a custom stream buffer that
just silently discards all calls to it, this not only fixes the bug
but also doubles the performance of associated osg::notify() calls.
An svn update will give you this fix.

Cheers,
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to