Execution bug - access violation

yoda

20-07-2006 10:30:11

Hi,
I have created a program which use oFusion. I have a bug due to TinyXML and i don't understand why. I have made two programs to test oFusion, the first one works fine, the second bugs.

int main(int a , char ** b)
{
try{
Ogre::Root* mRoot = new Ogre::Root("plugins.cfg","ogre.cfg","ogre.log");
Ogre::GLRenderSystem* mRender = new Ogre::GLRenderSystem();
mRoot->setRenderSystem( mRender );
mRoot->initialise(false);
Ogre::RenderWindow* mWindow = mRoot->createRenderWindow("Main", 800, 600, false );
Ogre::ConfigFile cf;
cf.load("resources.cfg");
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
cout << "a-" ;
Ogre::String secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
for (Ogre::ConfigFile::SettingsMultiMap::iterator i = settings->begin();
i != settings->end(); ++i)
{
cout << "b-" ;
Ogre::String typeName = i->first;
Ogre::String archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
Ogre::SceneManager* mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC,"sceneManager");
OSMScene oScene = OSMScene( mSceneManager, mWindow);
oSceneCallback oe_Callback;
oScene.initialise("scene.osm", &oe_Callback);
...


int main(int a , char ** b)
{
try{
Ogre::Root* mRoot = new Ogre::Root("plugins.cfg","ogre.cfg","ogre.log");
Ogre::GLRenderSystem* mRender = new Ogre::GLRenderSystem();
mRoot->setRenderSystem( mRender );
mRoot->initialise(false);
Ogre::AlterWin32* mWindow = new Ogre::AlterWin32();
mRender->attachRenderTarget( *mWindow );
Ogre::HardwareBufferManager* mHardwareBufferManager = new Ogre::DefaultHardwareBufferManager();
Ogre::Win32GLSupport* support = new Ogre::Win32GLSupport();
Ogre::TextureManager* mTextureManager = new Ogre::GLTextureManager(*support);
Ogre::ConfigFile cf;
cf.load("resources.cfg");
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
cout << "a-" ;
Ogre::String secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
for (Ogre::ConfigFile::SettingsMultiMap::iterator i = settings->begin();
i != settings->end(); ++i)
{
cout << "b-" ;
Ogre::String typeName = i->first;
Ogre::String archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );

Ogre::SceneManager* mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC,"sceneManager");
OSMScene oScene = OSMScene( mSceneManager, mWindow);
oSceneCallback oe_Callback;
oScene.initialise("scene.osm", &oe_Callback);
...

The AlterWin32 class is one of mine, and it didn't do anything. I have located the part of the code which crashs my program:

returnNode = new TiXmlElement( "" ); in the TiXmlNode::Identify function in the TinyXMLParser.cpp file
value = _value; int the TiXmlElement::TiXmlElement contructeur in the tinyXMLL.cpp file.

I have the bug:

main.exe caused an Access Violation at location 641a3734 in module libstdc++.dll Reading from location 3f800000.

Registers:
eax=00000000 ebx=00000014 ecx=641ca5b8 edx=3f800000 esi=00000004 edi=0022fbf0
eip=641a3734 esp=0022fb60 ebp=0022fb78 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206

Call stack:
641A3734 libstdc++.dll:641A3734 _ZNSt24__default_alloc_templateILb1ELi0EE8allocateEj
64198285 libstdc++.dll:64198285 _ZNSs4_Rep9_S_createEjRKSaIcE
64199608 libstdc++.dll:64199608 _ZNSs9_M_mutateEjjj
64197ED1 libstdc++.dll:64197ED1 _ZNSs15_M_replace_safeIPKcEERSsN9__gnu_cxx17__normal_iteratorIPcSsEES6_T_S7_
64199F2B libstdc++.dll:64199F2B _ZNSsaSEPKc
0040CD7E main.exe:0040CD7E
0041046D main.exe:0041046D
0040FE80 main.exe:0040FE80
0040251D main.exe:0040251D
0040B325 main.exe:0040B325
00401237 main.exe:00401237
00401288 main.exe:00401288
7C816D4F kernel32.dll:7C816D4F RegisterWaitForInputIdle

Could you help me?

Lioric

22-07-2006 03:42:40

In what compiler is your application created?

Can you do a step debug and see why the crash is, can you check the registers state in the line where the issue is?

yoda

24-07-2006 08:13:45

I use gcc.exe (GCC) 3.2.3 (mingw special 20030504-1). I can't do a step debug i think. sorry.