1

Working with OpenSceneGraph, and I keep running into this violation issue that I would appreciate some help with. The problem is with the particular line below which happens to be the first in my main function.

 osg::ref_ptr<osg::Node> bench = osgDB::readNodeFile("Models/test.IVE");

I have my models folder right in my directory. The error is as below.

Unhandled exception at 0x68630A6C (msvcr100.dll) in OSG3D.exe: 0xC0000005: Access violation reading location 0x00421000.

And this is where the problem seems to be coming up.

/** Read an osg::Node from file. 
  * Return valid osg::Node on success,
  * return NULL on failure.
  * The osgDB::Registry is used to load the appropriate ReaderWriter plugin
  * for the filename extension, and this plugin then handles the request
  * to read the specified file.*/
inline osg::Node*  readNodeFile(const std::string& filename)
{
    return readNodeFile(filename,Registry::instance()->getOptions());
}

I would appreciate details on how best to tackle this kind of exception message in the future. Are there tools that make this easy to debug or are there ways to capture the exact issues and fix them? I would appreciate any help with this.

My ultimate goal is to learn how to better debug C++ related issues please. With this, it means reading through the compiler error list http://msdn.microsoft.com/en-us/library/850cstw1(v=vs.71).aspx is not enough

Kobojunkie
  • 6,375
  • 31
  • 109
  • 164
  • And I am running Visual Studio 2012 as Administrator. – Kobojunkie Nov 07 '12 at 16:41
  • Any help with this please? I am still pulling hair here trying to figure out a way around this problem. – Kobojunkie Nov 08 '12 at 02:36
  • Try to reinstall the VS2012 redist package since it seems your problem occurs there. – count0 Nov 08 '12 at 16:14
  • Can I ask how you came about that being where the issue might be coming from please? I ask because I want to know how to debug this next time. – Kobojunkie Nov 08 '12 at 17:55
  • I reinstalled VS 2012 redistributable package from http://www.microsoft.com/en-us/download/details.aspx?id=30679 but the problem persists. – Kobojunkie Nov 08 '12 at 18:34
  • I rebuilt my whole application in 2010, and download for use instead the 2010 release of OpenSceneGraph but that did not seem to make this issue disappear. I am desperate for good suggestions on how to resolve this issue please. – Kobojunkie Nov 09 '12 at 02:01
  • Can you reproduce it with a small sample application that you could post? – Skrymsli Nov 28 '12 at 22:20
  • Did you check the callstack when the exception occured? Are there some DLLs should not in that callstack? – Matt Nov 29 '12 at 02:56
  • I used to deal with similar problem: our program crashed on only one customer machine, I got the mini dump file and spent days on it, finally, I found some suspicious DLLs on the callstack, and they belows to an anti virus software, I asked the customer to remove the anti virus software, then it works fine. I think it is because the anti virus software used the old VC runtime, and my program used the new one, which cause some malloc/free mismatch, then caused the problem. BTW, you can give MS App Verifier a try, it can help to find memory problems. – Matt Nov 29 '12 at 03:03

3 Answers3

1

enter image description here

After testing, it is found that either

  • You are compiling the code in debug mode, but using release libs/dlls or
  • You are compiling the code in release mode, but using debug libs/dlls.

So simply use debug osg lib for debug build, and release version for release build, done.

enter image description here

David
  • 15,894
  • 22
  • 55
  • 66
0

I've had good luck resolving similar issues by using tools such as Application Verifier (from Microsoft). GFlags and similar tools are also good.

Application Verifier installs easy, then you point it to your exe and run the application in Visual Studio. When the issue happens it will break the application where it finds the issue. This may or may not be exactly where the issue happens (though I've had good luck landing right where it first started) but it should be easier to see what could be going on.

Were you able to open up the program? Microsoft installs it in C:\Windows\System32\appverif.exe. When you run it, you select the file and also what you want to debug. In your case choose memory related options. Activate App Verifier and it should tell you that you now should run it in Visual Studio. So, run your program in Visual Studio and App Verifier should help stop your program at the location the error occurred (or close by). Google for Application Verifier. There are some nice tutorials.

Gustavo Litovsky
  • 2,457
  • 1
  • 29
  • 41
0

Please do the following troubleshooting:

  1. check where is your Model folder, suppose you should copy it under debug or release folder, since they are the default execute path.

  2. add some protection code before your read the node files, you must ensure the file exists before you read it.

  3. Construst a ReaderWriter::Options directly and replace Registry::instance()->getOptions() and see if issue is still.

And I think Design by Contract is good to avoid most of this kind of issues.

ray_linn
  • 1,382
  • 10
  • 14