Game Development Community

Bug in getArgBuffer(size) effecting script callbacks with more than one parameter - LOGGED

by Joti · in Torque 3D Professional · 02/22/2011 (7:59 am) · 3 replies

I was having trouble getting multiple values passed to script callbacks I created on GuiMouseEventCtrl for touch events and I traced it back to an issue in Con::getArgBuffer().

Looks like a typo to me. My fix.

char *getArgBuffer(U32 size)  
   {  
      validateBufferSize(mStart + mFunctionOffset + size);  
   // start jc  
   //   char *ret = mBuffer + mStart + mFunctionOffset;  
      char *ret = mArgBuffer + mStart + mFunctionOffset;  
   // end jc  
      mFunctionOffset += size;  
      return ret;  
   }

I would have thought this one would have caused more trouble.

I posted the fix on this thread as well.
www.garagegames.com/community/forums/viewthread/120561/1#comment_form

About the author

Recent Threads


#1
03/21/2011 (1:32 pm)
Logged as THREED-1503.
#2
03/25/2011 (8:23 am)
@whomever addresses this:

Careful, I don't think this is a fix. Pay close attention to what is going on in stringstack.h and what that fcn actually does. The function names in this class are not very clear, as several fcns manipulate the object when the fcn signature implies a simple get/validate/etc.



#3
03/25/2011 (11:57 am)
I agree with Bennett, I too have looked through stringStack.h and other files trying to come up with a final solution, but it is quite confusing as if somebody went through and made changes, but left them incomplete and inconsistent use of some of the variables/functions such as for using mArgBuffer.

Here is my diff for changes related to the same problem and the engine hasn't crashed so far for me, but it doesn't mean I'm correct:

--- Torque_Stock/Torque 3D 2009 Pro 1.1 Beta 3/Engine/source/console/stringStack.h	Thu Sep 16 18:01:58 2010
+++ TorqueModified/Torque 3D 2009 Pro 1.1 Beta 3/Engine/source/console/stringStack.h	Sat Feb 26 22:18:40 2011
@@ -108,8 +108,10 @@
    {
       if(size > ReturnBufferSpace)
       {
-         validateArgBufferSize(size);
-         return mArgBuffer;
+		  // attempting to fix mishandling of argument buffer bug --TRON
+		  return getArgBuffer(size);
+//         validateArgBufferSize(size);
+//         return mArgBuffer;
       }
       else
       {
@@ -123,8 +125,12 @@
    /// This updates the function offset.
    char *getArgBuffer(U32 size)
    {
-      validateBufferSize(mStart + mFunctionOffset + size);
-      char *ret = mBuffer + mStart + mFunctionOffset;
+//      validateBufferSize(mStart + mFunctionOffset + size);
+//      char *ret = mBuffer + mStart + mFunctionOffset;
+      validateArgBufferSize(mStart + mFunctionOffset + size);
+      char *ret = mArgBuffer + mStart + mFunctionOffset;
       mFunctionOffset += size;
       return ret;
    }

So, it just shows there's many different ideas on how to fix the problem, but I believe the real problem is that StringStack.h and associated code needs a revamp with comments on what is suppose to be going on.