Mogre creation functions returning null references


12-11-2007 15:17:27

Hi all,

I've been noticing a very strange behaviour with Mogre 0.2.2 creation routines. It happens very, very rarely, when one has a very large SceneNode/Entity creation ratio (e.g. 1 or 2 objects created every frame for a couple of seconds).

The issue is that when calling SceneManager.Create(), the returned reference is a null reference. For instance:

SceneNode node = manager.CreateSceneNode("testNode");

However, the strangest thing is that low-level Ogre has indeed created the SceneNode, for if I query it for a SceneNode with the creation name, it returns me the correct reference for the created object.

I emphasize that this has only happened at very high creation rates, and in a non-deterministic fashion. For now, and until I figure out what it is, I've been plugging in the following safe-guard code, for instance:

SceneNode node = manager.CreateSceneNode("testNode") ?? manager.GetSceneNode("testNode");

Note also that this happens with any creation method, not just CreateSceneNode(), but with CreateEntity(), or even CreateChildSceneNode() in SceneNode instances.

Anyone has any idea what could be the issue here? I'll try and revert to Mogre 0.2.0. to see if it pops up there as well.

Best regards,



15-11-2007 16:30:18

hi there!

i've had this problem before, it also happened as i switched to 0.2.2... i get null reference errors on the nodes i've previously created after a short while. I traced the problematic code by commenting out (one-by-one) pieces of my code and traced it to my input listener.

I dunno if this would also be the same case with you, but i solved my problem by moving my input handling to buffered input. i dunno why, but it fixed it. refer to:


15-11-2007 16:33:25

on the other hand, this post might help:


06-12-2007 17:39:54

Ok, I'm now fairly certain Mogre 0.2.2. has a bug... I don't know exactly how or what it is, except for the following properties:

1. Is generally widespread throughout Mogre.
2. The symptoms are the return of null references from Creation methods, Properties of objects, or more rarely from GetByName methods (e.g. node.ParentSceneNode, manager.CreateEntity, etc).
3. It seems to come out much more frequently in memory intensive managed-side applications.
4. It is non-deterministic in nature.

Points 3 and 4 make me believe that the bug is somehow related with garbage collection. Since on memory intensive applications there are lots more garbage collections, there is the possibility that some collection mid-access is nullifying some properties it shouldn't.

Reverting to Mogre 0.2.0. seems to fix practically all of these issues, although I will have to run more intensive tests to actually confirm it. On even earlier versions, the bug is absent altogether.

Perhaps some misbehaved compiler optimization?

I will try to code up a small readable example where this bug occurs so that you can analyze it.

Best regards,