Hello everyone,
I have a really frustrating situation on my hands here. I've made a simple
application that loads a scene and then does something with it. When I try to
load certain scenes, my program crashes occasionally(!) in release mode and
gives me this error:
Code:
Unhandled exception at 0x72e39083 in Diploma.exe: 0xC0000005: Access violation
reading location 0x02f0b154.
Other times everything seems to be working perfectly.
The address of the exception seems to be pointing to osg61-osg.dll
The call stack looks like this:
Code:
> osg61-osg.dll!72e39083()
[Frames below may be incorrect and/or missing, no symbols loaded for
osg61-osg.dll]
osg61-osg.dll!72e4678d()
osg61-osg.dll!72eac7c3()
osg61-osg.dll!72e8d23d()
osg61-osgUtil.dll!6ecde669()
osg61-osgUtil.dll!6ecdeaab()
osg61-osg.dll!72e70358()
osg61-osg.dll!72ebf7ff()
osg61-osgUtil.dll!6ecdea4d()
osg61-osg.dll!72e4e938()
osg61-osg.dll!72ebf7ff()
osg61-osg.dll!72f1a14e()
osg61-osgUtil.dll!6ecdea4d()
osg61-osg.dll!72e7f198()
osg61-osg.dll!72ebf7ff()
osg61-osgUtil.dll!6ecdea4d()
osg61-osg.dll!72e4e9b8()
osg61-osg.dll!72ebf7ff()
osg61-osgUtil.dll!6ecdea4d()
osg61-osg.dll!72e4e938()
osg61-osg.dll!72ebf7ff()
osg61-osgUtil.dll!6ecdea4d()
osg61-osg.dll!72e4e938()
osg61-osgViewer.dll!6ec4e473()
osg61-osgUtil.dll!6ed2d0b4()
osg61-osgViewer.dll!6ec500f7()
msvcp90.dll!74124f2a()
osg61-osg.dll!72ebf10a()
ot11-OpenThreads.dll!75742098()
msvcr90.dll!741d3433()
msvcr90.dll!741d34c7()
kernel32.dll!760c3677()
ntdll.dll!77d09d72()
ntdll.dll!77d09d45()
Now, I've read all about Heisenbugs and differences between Debug and Release
modes, so I know it's my fault, but if you look at the code, the program
doesn't crash until the last line, when there's a call to viewer->run():
Code:
root = new osg::Group;
viewer = new osgViewer::Viewer(arguments);
//the non-colored scene that will be shown before and after the
algorithm
sceneNoColor = osgDB::readNodeFiles(arguments);
TextureRemover *textureRemover = new TextureRemover;
osgDB::Registry::instance()->setReadFileCallback(textureRemover);
// read the scene from the list of file specified commandline args.
scene = osgDB::readNodeFiles(arguments);
if (!scene || !sceneNoColor)
{
osg::notify(osg::NOTICE)<<"No model loaded"<<std::endl;
exit(1);
}
osg::ref_ptr<PrimitiveCountVisitor> primitiveCountVisitor = new
PrimitiveCountVisitor;
scene->accept((*primitiveCountVisitor));
long numPrimitives = primitiveCountVisitor->getNumPrimitives();
postDrawCallback = new SnapImage("PostDrawCallback.png", numPrimitives,
osg::Vec4(1.f, 1.f, 1.f, 1.f));
scene->setDataVariance(osg::Object::DYNAMIC);
osg::ref_ptr<GeometryPaintVisitor> paintVisitor = new
GeometryPaintVisitor(numPrimitives);
scene->accept((*paintVisitor));
osg::ref_ptr<osg::Switch> mainSwitch = new osg::Switch;
mainSwitch->addChild(sceneNoColor);
mainSwitch->addChild(scene);
mainSwitch->setSingleChildOn(0);
mainSwitch->setName("ij_MainSwitch");
osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
osg::Matrix m;
osg::Vec3f boundingSphereCenter = scene->getBound().center();
m.setTrans( -boundingSphereCenter.x(), -boundingSphereCenter.y(),
-boundingSphereCenter.z() );
mt->setMatrix( m );
if (mainSwitch.valid())
{
mt->addChild(mainSwitch.get());
root->addChild(mt.get());
}
//compute the center point and the radius of the bounding sphere
osg::BoundingSphere boundingSphere = mt->getBound();
boundingSphereRadius = boundingSphere.radius();
boundingSphereCenter = boundingSphere.center();
viewer->getCamera()->setPostDrawCallback(postDrawCallback.get());
osg::ref_ptr<osg::Group> newRoot = new osg::Group;
newRoot->addChild(root.get());
newRoot->setName("rootNode");
// add the HUD subgraph.
newRoot->addChild(createHUD().get());
root = newRoot.get();
// set the scene to render
viewer->setSceneData(root.get());
viewer->getCamera()->setClearColor(osg::Vec4f(1.f, 1.f, 1.f, 1.f));
return viewer->run();
I guess I'm corrupting some memory, which the viewer->run() then uses, but I
can't find what I'm doing wrong because the debugger won't let me into the
run() method. The program crashes before showing the scene on the screen.
Does anyone know how to tackle this problem?
Thank you in advance.
Inos
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=28115#28115
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org