Weirdest crash ever

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Weirdest crash ever

Post 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?
Never take advice from someone who likes to give advice, so take my advice and don't take it.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

You could add a pointer for the mesh and test if the mesh was correctly loaded
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post 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")
Never take advice from someone who likes to give advice, so take my advice and don't take it.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post 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?
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post 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.
Never take advice from someone who likes to give advice, so take my advice and don't take it.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post 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...
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post 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".
Never take advice from someone who likes to give advice, so take my advice and don't take it.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Hmmm...yes, I'm too drunk for this .__.
I don't know what could create this error, sorry
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

what does the debugger says?
Iyad
Posts: 140
Joined: Sat Mar 07, 2009 1:18 am
Location: Montreal, Canada

Post 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.
#include <Iyad.h>
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post 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.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post 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
Never take advice from someone who likes to give advice, so take my advice and don't take it.
ericklima.comp
Posts: 9
Joined: Tue Jan 05, 2010 3:06 pm
Location: Brazil

Post 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... =(
Erick
Post Reply