[Hastur 0.15.2] Exception when creating SceneNode

Problems building or running the engine, queries about how to use features etc.
GangMan
Gnoblar
Posts: 10
Joined: Tue Nov 09, 2004 7:19 pm
Location: Hagenberg, Austria

[Hastur 0.15.2] Exception when creating SceneNode

Post by GangMan »

Hello everyone!

I just downloaded and compiled the new OGRE 0.15.2 release build and was very happy to read that the Debug-Shutdown bug was fixed.
But before I was even able to test that another problem occurred:
My application now crashes with an unhandled exception, everytime a SceneNode is created.

Code: Select all

Unhandled exception at 0x1040061d in PathFinderd.exe: 0xC0000005: Access violation reading location 0x0000010c.
I create SceneNodes the following way:

Code: Select all

SceneNode* testNode = static_cast<SceneNode*>(SceneManagerWrapper::getInstance()->getRootSceneNode()->createChild());
I wrote this singleton wrapper class so I can access my sceneManager object from every class.

The program (still) works fine, when I use 0.15.1, but with 0.15.2 I get this exception everytime I create a node.
Has anyone had a similar problem? Have I missed important changes from 0.15.1 to 0.15.2? Are SceneNodes created differently? Since I only get disassembly debug informations, debugging is not really effective but I have noticed that SceneManagerWrapper::getInstance() normally returns the SceneManager object but when getRootSceneNode() is called, the exception occurs.
Any ideas?
User avatar
Banania
Gremlin
Posts: 150
Joined: Wed Oct 20, 2004 2:35 pm
Location: Paris, France

Post by Banania »

Are you sure your getInstance() method returns a proper pointer ?
This kind of error usually comes from bad pointers.
Banania
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8

Post by haffax »

You can post your SceneManagerWrapper implementation and we can have a look at it. As Banania said the bad pointer is the most probable reason.

Aside: instead of creating the SceneNodes with createChild() you should create them with createChildSceneNode(). This spares you the ugly cast.
team-pantheon programmer
creators of Rastullahs Lockenpracht
GangMan
Gnoblar
Posts: 10
Joined: Tue Nov 09, 2004 7:19 pm
Location: Hagenberg, Austria

Post by GangMan »

Okay, hang on:

SceneManagerWrapper.h

Code: Select all

#ifndef SCENEMANAGERWRAPPER_H
#define SCENEMANAGERWRAPPER_H

#include "Ogre.h"

using namespace Ogre;

class SceneManagerWrapper
{
public:
    /**
     *	Initialises the wrapper by passing on the root node. It is used for
     *  retrieving a scene manager
     */
    static void init(Root* root);

    /**
     *	Returns a single instance of the scene manager. It is the only one
     *  available through out the whole application to avoid inconsitencies.
     */
    static SceneManager* getInstance();
private:
    /// The scene manager that manages how the scene is rendered.
    static SceneManager* mSceneManager;
};

#endif // SCENEMANAGERWRAPPER_H
SceneManagerWrapper.cpp

Code: Select all

#include "SceneManagerWrapper.h"

void SceneManagerWrapper::init(Root* root) {
    mSceneManager = root->getSceneManager(ST_GENERIC);
}

SceneManager* SceneManagerWrapper::getInstance() {
    return mSceneManager;
}

SceneManager* SceneManagerWrapper::mSceneManager = 0;
To create a SceneManager, "init()" should be called in the Application class, passing on the root-object. getInstance returns the sceneManager.
I understand the idea with the bad pointer but I wonder why it worked with 0.15.1...
Last edited by GangMan on Tue Jan 18, 2005 3:57 pm, edited 2 times in total.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Nothing has changed in 0.15.2 regarding the creation of scene nodes, so I suspect something else has gone awry during your upgrade. It's clearly a null pointer - the question is where; perhaps you could just step your debugger through the sub-parts of that failing line and find out which part is null.
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK

Post by SpannerMan »

This is just a guess ( sill learning myself ), but shouldnt

Code: Select all

SceneManager* PathFinderSceneManagerWrapper::mSceneManager = 0;
Be

Code: Select all

SceneManager* SceneManagerWrapper::mSceneManager = 0;
:?:
GangMan
Gnoblar
Posts: 10
Joined: Tue Nov 09, 2004 7:19 pm
Location: Hagenberg, Austria

Post by GangMan »

SpannerMan, you're of course right. I used PathFinder... in my Application but removed it from the codesamples not to confuse anyone. But it seems like I forget to replace this one. :)

I corrected the code above.

I'm currently rebuilding OGRE to see if there were any warnings I might missed. I compiled it without checking the warnings - maybe the problem is related to building OGRE.
Last edited by GangMan on Tue Jan 18, 2005 4:04 pm, edited 1 time in total.
User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

try moving the last line to make it right below the header, it might be overriding the value after its set (probably not,b ut you never know :))
phear hingo

My Webpage
GangMan
Gnoblar
Posts: 10
Joined: Tue Nov 09, 2004 7:19 pm
Location: Hagenberg, Austria

Post by GangMan »

Okay, I rebuilt OGRE and looked through the warnings. Besides all the conversion warnings I got this one when Linking OgreMain in Debug Configuration (warning also occurs for Relase config but since I'm only using Debug atm, it shouldn't matter).

Code: Select all

LINK : warning LNK4098: defaultlib 'LIBC' conflicts with use of other libs; use /NODEFAULTLIB:library
Is this serious? Could this be responsible for the error? Is something linked wrong?

Additionally, I saw something, that doesen't belong to this problem, but I'll mention it here anyway: When zlib is linked, the following errors occur:

Code: Select all

zlib.lib(adler32.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(crc32.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(zutil.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(inflate.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(infblock.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(inftrees.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(infcodes.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(infutil.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
zlib.lib(inffast.obj) : warning LNK4099: PDB 'vc60.pdb' was not found with '..\..\Dependencies\lib\Debug\zlib.lib' or at 'd:\Programme\ogrenew\OgreMain\lib\Debug\vc60.pdb'; linking object as if no debug info
I know, these errors have anything to do with the problem, but why is OGRE looking for vc6 pdbs even though I'm using VS7.1?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

None of these are problems, you can ignore them. For simplicity, the dependencies were built with VC6 so they are compatible with all versions of VC. In 1.0.0 I'll probably be distributing 2 separate versions and you won't get the warnings.

Your best bet is really the debugger. You need to decompose that call and find out which one is giving you a null pointer.
GangMan
Gnoblar
Posts: 10
Joined: Tue Nov 09, 2004 7:19 pm
Location: Hagenberg, Austria

Post by GangMan »

sinbad wrote:Your best bet is really the debugger. You need to decompose that call and find out which one is giving you a null pointer.
Okay. I have to admit, I'm not an expert, when it comes to debugging. So please forgive me the question, but how can I effectively debug an application? Whenever I set a breakpoint at

Code: Select all

SceneNode* testNode = static_cast<SceneNode*>(SceneManagerWrapper::getInstance()->getRootSceneNode()->createChild());
and continue via "Step into" I can step into my own wrapper but then, when it comes to getRootSceneNode() or createChild() I have no access to any sources. Am I right, that this is because I just include the OgreMain_d.lib and not the whole sources in my project? But if so, how can I effectively find out, where the application produces a null pointer?

I tried to split up the node creation into three parts:

Code: Select all

SceneManager* sceneManager = SceneManagerWrapper::getInstance();
SceneNode* rootNode = sceneManager->getRootSceneNode();
SceneNode* childNode = static_cast<SceneNode*>(rootNode->createChild());
sceneManager and rootNode are created, both objects are not null. But wenn createChild() is called, the exception is thrown. So I guess, something goes wrong inside createChild(). Is there a way to find out?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

It sounds like you don't have the Ogre source on your machine, or you've copied the Ogre libraries from some other machine where the link to the debugging information, which is in the .pdb file, is missing. You should be able to step into the Ogre code (after all, we do provide a full source release).

There's nothing in createChild which should cause a crash unless you have some serious incompatibilities with your libs I think. Are you definitely using OgreMain_d.dll in debug mode?
GangMan
Gnoblar
Posts: 10
Joined: Tue Nov 09, 2004 7:19 pm
Location: Hagenberg, Austria

Post by GangMan »

Okay, I found the problem. I tried to avoid placing my executable into the Common/bin folder. Therefore I had VS create it in the path of my application and copied the necessery DLLs into that directory as well. Somehow, I totally forgot about that, when upgrading to 0.15.2, don't ask me why. Anyway, I placed the correct dlls into that directory and everything works fine again. I can also debug into Ogre files now again. Kinda embarrassing...

sinbad (and of course all the others), thanks a lot for helping. I'm really sorry I wasted your time with this eventually simple and stupid issue.
The community here is really great since people are always trying to help - even if the problems are plain and simple.