Page 1 of 1

Weirdest crash ever

Posted: Fri Aug 06, 2010 9:54 pm
by Bate
Alright, this is the weirdest thing I've ever seen:

I made a simple createMap function and everything works just fine if I compile and start the program from inside MSVS2010 (Release Mode).

function looks like this

Code: Select all

bool createMap()
{

// loop and add some meshs
// really trivial, nothing extraordinary here

// then a single call
smgr->addMeshSceneNode(smgr->getMesh("HQ.x"));

return true;
}
Now, if I start the compiled program from outside the IDE the program just crashs due to a memory read error.

So, I fired up the just-in-time-debugger and it tells me the line

Code: Select all

smgr->addMeshSceneNode(smgr->getMesh("HQ.x"));
causes the crash.

If I delete that line the executable works perfectly fine and all the other meshs get loaded.

- There is no problem with the mesh (works in the meshviewer and as mentioned everything's ok if run from inside the IDE)
- Tested with official Irrlicht dll
- The file is in the same folder
- Console output says everything except HQ.x got loaded correctly, then the crash occurs

The million dollar question:
What the hell is going on?

Posted: Fri Aug 06, 2010 10:03 pm
by cookie
You could add a pointer for the mesh and test if the mesh was correctly loaded

Posted: Fri Aug 06, 2010 10:08 pm
by Bate
Why? The crash occures in addMeshSceneNode, so I already know it wasn't loaded correctly.

[edit]
ah you wanna see if it's about the adding or about the getting.
it's the getMesh("HQ.X")

Posted: Fri Aug 06, 2010 10:16 pm
by cookie
Did you try to load another mesh? The only problem which could be is the mesh... or your sceneManager isn't avaible in this function?

Posted: Fri Aug 06, 2010 10:33 pm
by Bate
The smgr is there and working. Loading all the other models within the same function just 1 line before works fine.

It really looks like that:

Code: Select all

smgr->getMesh("A.x"); // works
smgr->getMesh("B.x"); // works
smgr->getMesh("C.x"); // works
smgr->getMesh("D.x"); // crash
Also, keep in mind: It only crashs if I run it from outside the IDE. In VStudio the last model loads and works as well (no problem in the meshviewer either). So, it really can't be anything obvious.

Posted: Fri Aug 06, 2010 10:38 pm
by cookie
When it just crash outside of the IDE then the path isn't correct to the mesh, because working directory of the IDE is a different as the working path in the exe...

Posted: Fri Aug 06, 2010 10:45 pm
by Bate
I appreciate your help but maybe you should read the first post again ;)
Besides: even if the file wasn't there (which it is) the application wouldn't crash. Irrlicht would simply say "couldn't load file".

Posted: Sat Aug 07, 2010 12:30 am
by cookie
Hmmm...yes, I'm too drunk for this .__.
I don't know what could create this error, sorry

Posted: Sat Aug 07, 2010 12:36 am
by Virion
what does the debugger says?

Posted: Sat Aug 07, 2010 5:29 am
by Iyad
Im not sure but I had almost the same error, i get it only by using opengl renderer on an old ati radeon card. When crashing, just check out if the bug occured in another dll than Irrlicht, if its the case,then you have some driver problems, otherwise, its an unknown irrlicht bug.

Posted: Sat Aug 07, 2010 6:08 am
by Virion
not sure if that's the visual studio version dll's bug or what because i'm using gcc's dll and I have the habit of running my exe outside my IDE, which, never had a problem.

Posted: Sat Aug 07, 2010 9:14 am
by Bate
I'm using D3D9 and a rather modern ATI 4800HD card. The crash occurs in Irrlicht.dll.

However, I did some more testing and now I believe there might be a bug in Irrlicht's mesh loader or file system.

Here's a compilable example:

obj File is in text format
X File is in binary format

Code: Select all

#include <Irrlicht.h>

using namespace irr;
using namespace video;
using namespace core;
using namespace scene;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

int main()
{
  IrrlichtDevice *device = createDevice(EDT_DIRECT3D9, dimension2du(800,600), 32, 0, 0, 1);

  IVideoDriver    *driver = device->getVideoDriver();
  ISceneManager   *smgr   = device->getSceneManager();

  device->getFileSystem()->addFileArchive("data/", true, true, EFAT_FOLDER);

  smgr->getMesh("border.obj");
  smgr->getMesh("HQ.X");

  while(device->run())
  {
    driver->beginScene(true, true, SColor(0, 0, 0, 0));
      smgr->drawAll();
    driver->endScene();
  }

  device->drop();
  return 0;
}
Files in subfolder "data"

run inside IDE :
all good

run exe :
Loaded mesh: border.obj
Unknown data object in animation of .x file: DWORD
Loaded mesh: HQ.X

--------------------------------------------------

Code: Select all

  device->getFileSystem()->addFileArchive("data/", true, true, EFAT_FOLDER);

  // smgr->getMesh("border.obj");
  smgr->getMesh("HQ.X");
Files in subfolder "data"

run inside IDE :
all good

run exe :
all good

--------------------------------------------------

Code: Select all

  // device->getFileSystem()->addFileArchive("data/", true, true, EFAT_FOLDER);

  smgr->getMesh("border.obj");
  smgr->getMesh("HQ.X");
Files in the same folder

run inside IDE :
all good

run exe :
all good

--------------------------------------------------

I've no idea why it doesn't crash like that anymore, but there are still weird things going on.

Here are the files

Posted: Fri Aug 20, 2010 1:57 pm
by ericklima.comp
I think it might be a bug on the FileSystem.
I'm getting an error when I try to Load a simple Texture.
I added one texture, then I tried to load another one and the application
crashed on the the getTexture() function.
A curious thing is that I just loaded this texture before and it worked.
I debugged it in all ways I could think and
I have no idea what I'm gonna do... =(