Ragdoll back and dSprintF error
by Tim Lang · in Artist Corner · 08/30/2007 (12:04 am) · 11 replies
This post wasn't getting any action in the private forums, so I thought I'd move it into a public one...
I'm not sure what forum to put this in, but it only happens after I've compiled the engine,...so here goes.
I just finished setting up Chris Calef's Ragdoll Animation Kit.
I followed the instructions (twice!) and compiled the engine. When I try to run the game, I get this error:
"dsprintf wrote to more memory than the specified buffer size"
here's the console log:
I have no idea where to even start to look to try to fix this.
anyone have any ideas??
EDIT:
After going into tsShapeConstruct.cc and switching #define TS_IS_RELATIVE_SEQUENCES 1 back to #define TS_IS_RELATIVE_SEQUENCES 0 the bug disappeared, so I suspect that it's the bit of code that says
but I don't know what to put in there to fix it. any suggestions?
I'm not sure what forum to put this in, but it only happens after I've compiled the engine,...so here goes.
I just finished setting up Chris Calef's Ragdoll Animation Kit.
I followed the instructions (twice!) and compiled the engine. When I try to run the game, I get this error:
"dsprintf wrote to more memory than the specified buffer size"
here's the console log:
*** New Mission: Dragonfire.test/data/missions/RockandRollStreet.mis *** Phase 1: Download Datablocks & Targets Mapping string: MissionStartPhase1Ack to index: 0 Error: shape Dragonfire.test/data/shapes/crossbow/ammo.dts-collision detail 1 (Collision-3) bounds box invalid! Error: shape Dragonfire.test/data/shapes/Microphone/ammo.dts-collision detail 1 (Collision-3) bounds box invalid! Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Validation required for shape: Dragonfire.test/data/shapes/player/player.dts Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Validation required for shape: Dragonfire.test/data/shapes/player/player.dts Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Could not locate texture: Dragonfire.test/data/shapes/kork/crossbow Could not locate texture: Dragonfire.test/data/shapes/kork/clip Validation required for shape: Dragonfire.test/data/shapes/kork/kork.dts Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Could not locate texture: Dragonfire.test/data/shapes/player/base.lmale Could not locate texture: Dragonfire.test/data/shapes/kork/crossbow Could not locate texture: Dragonfire.test/data/shapes/kork/clip Validation required for shape: Dragonfire.test/data/shapes/kork/kork.dts Fatal: (j:\video games\dragonfire\dragonfire riots\engine\platformwin32\winstrings.cc @ 296) dSprintf wrote to more memory than the specified buffer size keyboard0 input device created. mouse0 input device created. joystick0 input device created. keyboard0 input device created. mouse0 input device created. joystick0 input device created. keyboard0 input device created. mouse0 input device created.
I have no idea where to even start to look to try to fix this.
anyone have any ideas??
EDIT:
After going into tsShapeConstruct.cc and switching #define TS_IS_RELATIVE_SEQUENCES 1 back to #define TS_IS_RELATIVE_SEQUENCES 0 the bug disappeared, so I suspect that it's the bit of code that says
if (TS_IS_RELATIVE_SEQUENCES) {
dSprintf(pathedSeq,90,"%s%s",shapePath,mSequence[i]);
mSequence[i] = StringTable->insert(pathedSeq);but I don't know what to put in there to fix it. any suggestions?
About the author
#2
08/30/2007 (10:02 am)
I'm not sure. How do I do that?
#3
08/30/2007 (10:13 am)
Please be very careful regarding how much code gets talked about here--I'm fine with a few lines, but please don't go overboard :)
#4
looks like 90 is the specified buffer size (hard coded, yuck..)
it should be a calculated value based on the size of shapePath and mSequence[i]
why is it overwriting mSequence[i] right after usage? that seems weird.
08/30/2007 (10:42 am)
DSprintf(pathedSeq,90,"%s%s",shapePath,mSequence[i]);looks like 90 is the specified buffer size (hard coded, yuck..)
it should be a calculated value based on the size of shapePath and mSequence[i]
why is it overwriting mSequence[i] right after usage? that seems weird.
#5
I think you're right. I'm totally clueless when it comes to knowing how to implement something like that. is there some kind of getSize function I can use?
here's my guess (hopefully I won't be too far off...)
am I even close with that?
@Stephen:
No prob. If I accidentally put too much in here, lemme know!
08/30/2007 (10:56 am)
@ Badguy:I think you're right. I'm totally clueless when it comes to knowing how to implement something like that. is there some kind of getSize function I can use?
here's my guess (hopefully I won't be too far off...)
%shapePathSize = shapePath.getSize(); %mSequenceSize = mSequence[i].getSize(); %bufferSize = %shapePathSize + mSequenceSize; then finally DSprintf(pathedSeq,%bufferSize,"%s%s",shapePath,mSequence[i]);
am I even close with that?
@Stephen:
No prob. If I accidentally put too much in here, lemme know!
#6
also I do not think .getSize() will be an available method.
I think dStrLen is your friend here.
int len = dStrLen(shapePath) + dStrLen(mSequence[i]);
then replace 90 with len.
08/30/2007 (12:41 pm)
The syntax is off, we are in c++ so no need for the % also I do not think .getSize() will be an available method.
I think dStrLen is your friend here.
int len = dStrLen(shapePath) + dStrLen(mSequence[i]);
then replace 90 with len.
#7
That's what you get when a designer starts writing code ;)
Thanks for your help...I'll try dStrLen tonight!
08/30/2007 (5:00 pm)
Doh! forgot that it wasn't scripting.That's what you get when a designer starts writing code ;)
Thanks for your help...I'll try dStrLen tonight!
#8
any suggestions?
EDIT
ok, found the problem with that,....itS dStrlen (with the "L" in lowercase)
it didn't seem to help though. I tried setting the "90" to 100, and I got a different error:
clicking "Retry" crashed
clicking "Ignore" brings up this error:
Clicking ignore brings up a bunch of these errors, but the game finally loaded (although the new animations didn't work)
08/30/2007 (10:49 pm)
So after trying dStrLen, I got the following result:1>c:\torque\tge_1_5_2\engine\ts\tsshapeconstruct.cc(166) : error C3861: 'dStrLen': identifier not found
any suggestions?
EDIT
ok, found the problem with that,....itS dStrlen (with the "L" in lowercase)
it didn't seem to help though. I tried setting the "90" to 100, and I got a different error:
Run-Time Check Failure #2 - Stack around the variable 'shapePath' was corrupted.
clicking "Retry" crashed
clicking "Ignore" brings up this error:
Run-Time Check Failure #2 - Stack around the variable 'pathedSeq' was corrupted.
Clicking ignore brings up a bunch of these errors, but the game finally loaded (although the new animations didn't work)
#9
I changed the 90s to 100, and now it seems to load just fine. Not sure if the animations work yet though.
Thanks for the help!!
08/30/2007 (11:21 pm)
Ok, forget all that. there's a line at the beginning of the function:char shapePath[90],pathedSeq[90];
I changed the 90s to 100, and now it seems to load just fine. Not sure if the animations work yet though.
Thanks for the help!!
#10
This is a case where a reasonable programmer would have had the train back on the tracks in five minutes or so, but for a non-programmer it takes much more effort.
Here's a version which is slightly improved:
08/31/2007 (9:29 am)
Way to weather through this, tim, but you raise a great point:Quote:That's what you get when a designer starts writing code.
This is a case where a reasonable programmer would have had the train back on the tracks in five minutes or so, but for a non-programmer it takes much more effort.
Here's a version which is slightly improved:
char shapePath[256], pathedSeq[256];...
AssertFatal(dStrlen(shapePath) + dStrlen(mSequence[i]) < sizeof(pathedSeq), "shapePath and sequence name are too long!"); dSprintf(pathedSeq, sizeof(pathedSeq),"%s%s",shapePath,mSequence[i]);
#11
08/31/2007 (10:04 am)
Awesome! thanks Orion!
Associate Orion Elenzil
Real Life Plus
but it sounds like a simple buffer overflow.
have you tried checking on the size of the strings and the buffer being passed to dSprintf ?