Crash bug with hack fix
by Stephen Zepp · in RTS Starter Kit · 11/12/2004 (7:25 pm) · 9 replies
Priority: Medium to Low
Category: Crash to Desktop
Reproducable: Yes
RTSBuildingMarker::onAdd makes an unprotected assumption that the .dts shape defined in mShapeInstance has animations (I think, there could be bigger issues in my .dts of course). When mShapeInstance->addThread() is called, it returns a NULL pointer which is assigned to mThread.
Two lines later, mThread is passed as a parameter in the call to mShapeInstance->setSequence( mThread, seq, 0.f ), which also makes an unprotected use of the pointer, causing a SEGFAULT to happen.
To reproduce: Assign any .dts that does not have any animation sequences to the RTSUnitData(TestBuildingBlock) datablock (mShapeBase =) in the appropriate places, and press the BUILD button once in game.
Hack fix:
in file RTSBuilding.cc, approx line 18, after the line
mThread = mShapeInstance->addThread();
add the following:
With this hack fix, it will let you place the building even without any anim sequences defined.
@GG: This is really a hack fix. I don't know if it makes sense to still let the player place the building, or if you should return false in this case (which gives console warnings, but does not let the building be placed). Any thoughts?
Category: Crash to Desktop
Reproducable: Yes
RTSBuildingMarker::onAdd makes an unprotected assumption that the .dts shape defined in mShapeInstance has animations (I think, there could be bigger issues in my .dts of course). When mShapeInstance->addThread() is called, it returns a NULL pointer which is assigned to mThread.
Two lines later, mThread is passed as a parameter in the call to mShapeInstance->setSequence( mThread, seq, 0.f ), which also makes an unprotected use of the pointer, causing a SEGFAULT to happen.
To reproduce: Assign any .dts that does not have any animation sequences to the RTSUnitData(TestBuildingBlock) datablock (mShapeBase =) in the appropriate places, and press the BUILD button once in game.
Hack fix:
in file RTSBuilding.cc, approx line 18, after the line
mThread = mShapeInstance->addThread();
add the following:
if (!mThread)
{
Con::printf("WARNING--RTSBuildingMarker::onAdd(): unable to add Thread for setting idle sequence!");
return true;
}This will avoid the crash by not allowing the call when mThread is NULL.With this hack fix, it will let you place the building even without any anim sequences defined.
@GG: This is really a hack fix. I don't know if it makes sense to still let the player place the building, or if you should return false in this case (which gives console warnings, but does not let the building be placed). Any thoughts?
#2
BTW, I hope you were out celebrating the RTS Kit release and not coding!
11/13/2004 (4:29 am)
Quote:Yes, but not right now, as it's almost 6am.
BTW, I hope you were out celebrating the RTS Kit release and not coding!
#3
11/13/2004 (7:43 pm)
Halo 2, actually. Got done around 4am and figured it wasn't worth it to sleep when I had to get up earlyish the next day. :)
#4
11/16/2004 (4:32 pm)
This is actually a very odd building. Why should addThread ever fail to return a thread?
#5
11/16/2004 (4:33 pm)
Did I say building? I meant crash. ;)
#6
11/16/2004 (4:33 pm)
Ah, no thread if there are no sequences.
#7
11/16/2004 (4:34 pm)
Added fix. :)
#8
11/16/2004 (5:00 pm)
Argh, that was my mistake. Good catch.
#9
self appointed master of Breaking TGE
11/16/2004 (5:13 pm)
Heh..it would take someone like me to drop in a totally screwed up building that had no animations to find, too!self appointed master of Breaking TGE
Associate Kyle Carter