Game Development Community

What does this mean?

by Cooper Sellers · in Torque Game Builder · 05/25/2006 (10:25 pm) · 12 replies

So I have had a few bugs laying about since the move to Beta3 (and now Beta4 as well) and I would like to try to lock these down. I have a nice little crash bug when I close the game that I am trying to figure out.

First off, when closing the game, the console gets hit with:

t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (16 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (12 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (4 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (24 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (59 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (10 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (10 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (9 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (9 ref)

What does this mean?

Also, one thing that I am doing that I am not sure if it is still supported, is the idea of setting the config value when declaring an object.

For example I am trying to do the following which might be the root of my crash. I have some datablocks, as so:

datablock t2dSceneObjectDatablock( NebShipDatablock ) 
{
	minLinearVelocity 	= 0;
	maxLinearVelocity 	= 50;
   .
   .
   .
};

datablock t2dSceneObjectDatablock( HammerDatablock : NebShipDatablock ) 
{
    minLinearVelocity 	= 0;
    maxLinearVelocity 	= 65;
    
   .
   .
   .
};

and then I am trying to use these like so:

%obj = new t2dStaticSprite( )
                {
                    config      = HammerDatablock;                    
                };

This all still runs just fine (after a few tweaks post Beta3) and gives me the desired result, but I do not know if this might somehow be causing my mysterious close game crash bug.

First off, is this still a legitimate thing to do and would this be causing some sort of crash on closure?

For reference, the crash is occuring in

SimObject::Notify* SimObject::removeNotify(void *ptr, SimObject::Notify::Type type)

with bad pointers...

Any thoughts?

#1
05/25/2006 (10:42 pm)
Okay, so if I remove the config line and place all of the datablock info into the delaraction of the sprite as so:

%obj = new t2dStaticSprite( )
                {
    minLinearVelocity 	= 0;
    maxLinearVelocity 	= 65;
   .
   .
   .
                };

Then I no longer get the crash. Does this mean that I am doing something wrong with the config parameter? Am I using it incorrectly? What is the best course of action?

Does this have something to do with the t2dStaticSpriteDatablock going away and my attempt at replacing it in the above sample with t2dSceneObjectDatablock?
#2
05/30/2006 (10:29 am)
Was this posted in the wrong forum?

Does the 'config = ' still work or not?
#3
05/30/2006 (12:02 pm)
Cooper,
this is logged in the bug tracker, so it will be investigated.

I've never had problems with config datablocks. Do you use tilemaps? Do you call delete() manually on any objects (especially in a onRemove() method)?
#4
05/30/2006 (12:17 pm)
Thanks for the info Michael.

I am using tilemaps for my background and have for quite some time. I am not manually calling delete() anywhere that I am aware of.
#5
05/30/2006 (12:48 pm)
Do you still get the crash regularly? If so, can you send me or Justin DuJardin your working directory (or a version of it that produces the crash). We have problems reproducing this bug. But I understand if you cannot or do not want to send your working directory to someone else.

Did you make any modifications to the c++ source? (because then it gets really hard)
#6
05/30/2006 (12:51 pm)
I do have modifications to the c++ code including adding support for windows XBOX controller as well as some added physics and some custom objects.

I will see if I can create a sample using the core engine and make sure this still occurs and get back to you.

If I am able to repro with core, what email should I send to?
#7
05/30/2006 (12:59 pm)
Send to: michaelwoerister at gmail dot com

Thank you very much for your effort :)
#8
05/30/2006 (2:40 pm)
Email sent
#9
05/31/2006 (3:32 am)
Ok, here is a possible solution: Config datablocks keep a list of objects referencing it. This list was not properly cleared on deletion which may have caused the bug. Here are the changes you have to make:

In t2dSceneObject.cc at about line 310:
bool t2dSceneObjectDatablock::onAdd()
{
    // Eventually, we'll need to deal with Server/Client functionality!

    // Call Parent.
    if(!Parent::onAdd())
        return false;

    [b]if( !mSceneObjects.registerObject() )
       return false;[/b]

    // Return Okay.
    return true;
}

[b]void t2dSceneObjectDatablock::onRemove()
{
   if( mSceneObjects.isProperlyAdded() )
      mSceneObjects.unregisterObject();

   Parent::onRemove();
}[/b]

and in t2dSceneObject.h at about line 67 in the t2dSceneObjectDatablock class declaration:
virtual bool onAdd();
    [b]virtual void onRemove();[/b]
    virtual void packData(BitStream* stream);

Add the bold printed lines. On my build the crash does not occur anymore. Please report back if this solves the problem for you too.

From what I see it is a nice game you have there :) And a bug in the OspreyDatablock definition. It should be GraphGroup instead of Group.

-Michael
#10
05/31/2006 (5:13 am)
Thank you for your time in looking into this. This did indeed remove the crash for me as well.

I did notice that I'm still getting the

t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (8 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (3 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (8 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (3 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (3 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)
t2dImageMapDatablock::onRemove() - Reference Count isn't zero but image-map is being destroyed! (2 ref)

upon shutdown though. Any indication if I should be concerned and if so, how to eliminate this?

Thank you for your time. And I wish we could show more of the game, there is lots more to see. Soon, I hope =)
#11
05/31/2006 (6:23 am)
Glad it worked :) I thank you for your time. Without your build and the hints you gave I would have taken ages to track down this bug.

The image map thing is not related to the other bug but it might be something similar. I don't know. But it is nothing to be worried about (other than it looks a bit ugly in the log file).
#12
05/31/2006 (7:17 am)
The "Reference Count" error has been about for the last couple of beta releases. I kind of got around it by manually using .safedelete() on all of my images before my game quit. It's quite an ugly work around though.

Hopefully it's something relatively simple in the underlying engine that GG will squash in the next release.