Game Development Community

Run-Time Check Failure #2 - Stack around the variable 'outstr

by Andrea Fraboni · in Torque Game Engine Advanced · 03/09/2008 (12:06 am) · 0 replies

Hi All

After a different update of the engine with different resources ..... I recompile more sessions ..... but now the Debug version of exe show different errors and shutdown !!

By VC I Debugging step by step and I see that the problem is in this resource :

DXDiagNVUtil.cpp

and in particular in these functions :

string DXDiagNVUtil::lpcwstrToString( const LPCWSTR in_lpcwstr )
{
   //@ consider using windows.h  WideCharToMultiByte(..)
   char * mbBuf;
   size_t sz;

   if( !in_lpcwstr || !in_lpcwstr[0] )
   {
      mbBuf = new char[2];
      mbBuf[0] = mbBuf[1] = 0;
   }
   else
   {
      sz = 2 * wcslen( in_lpcwstr );
      mbBuf = new char[sz];
      wcstombs( mbBuf, in_lpcwstr, sz );		// convert the string 
   }
   string outstr;
   outstr = mbBuf;
   SAFE_ARRAY_DELETE( mbBuf );
[b]   return( outstr );[/b]
}

and

int hackWToI( wstring & in_wstring)
{
   string t = DXDiagNVUtil::WStringToString(in_wstring);
  [b] return atoi(t.c_str()); [/b]
}

the list of errors :

Run-Time Check Failure #2 - Stack around the variable 'outstr' was corrupted.
Run-Time Check Failure #2 - Stack around the variable 't' was corrupted.
Run-Time Check Failure #2 - Stack around the variable 'outstr' was corrupted.
Run-Time Check Failure #2 - Stack around the variable 't' was corrupted.


Call Stack Window show this :


> TGEA_DEBUG.exe!NVDXDiagWrapper::DXDiagNVUtil::lpcwstrToString(const wchar_t * const in_lpcwstr=0x0012b1b0) Line 121 + 0xf bytes C++
TGEA_DEBUG.exe!NVDXDiagWrapper::DXDiagNVUtil::WStringToString(std::basic_string,std::allocator > & in_wstring="??0") Line 85 + 0x1c bytes C++
TGEA_DEBUG.exe!NVDXDiagWrapper::hackWToI(std::basic_string,std::allocator > & in_wstring="??0") Line 96 + 0xd bytes C++
TGEA_DEBUG.exe!NVDXDiagWrapper::DXDiagNVUtil::GetDirectXVersion(unsigned long * pdwDirectXVersionMajor=0x0012b314, unsigned long * pdwDirectXVersionMinor=0x0012b308, wchar_t * pcDirectXVersionLetter=0x0012b32c) Line 444 + 0x9 bytes C++
TGEA_DEBUG.exe!GFXD3DDevice::getDXVersion() Line 1795 C++
TGEA_DEBUG.exe!GFXD3DDevice::enumerateAdapters(Vector & adapterList={...}) Line 1838 + 0x5 bytes C++
TGEA_DEBUG.exe!GFXInit::enumerateAdapters() Line 23 + 0xa bytes C++
TGEA_DEBUG.exe!Platform::initWindow(const Point2I & initialSize={...}, const char * name=0x020abc58) Line 935 C++
TGEA_DEBUG.exe!ccreateCanvas(SimObject * __formal=0x00000000, int argc=2, const char * * argv=0x00f6b428) Line 105 + 0x22 bytes C++
TGEA_DEBUG.exe!CodeBlock::exec(unsigned int ip=38, const char * functionName=0x025d44fc, Namespace * thisNamespace=0x0245b248, unsigned int argc=1, const char * * argv=0x00f6b428, bool noCalls=false, const char * packageName=0x00000000, int setFrame=-1) Line 1095 + 0x22 bytes C++
TGEA_DEBUG.exe!CodeBlock::exec(unsigned int ip=215, const char * functionName=0x025d36f4, Namespace * thisNamespace=0x0245b248, unsigned int argc=0, const char * * argv=0x00f6b428, bool noCalls=false, const char * packageName=0x00000000, int setFrame=-1) Line 1021 C++
TGEA_DEBUG.exe!CodeBlock::exec(unsigned int ip=429, const char * functionName=0x024be5b0, Namespace * thisNamespace=0x0245b400, unsigned int argc=0, const char * * argv=0x00f6b428, bool noCalls=false, const char * packageName=0x025d37c4, int setFrame=-1) Line 1021 C++
TGEA_DEBUG.exe!CodeBlock::exec(unsigned int ip=21, const char * functionName=0x024be5b0, Namespace * thisNamespace=0x020bb5a8, unsigned int argc=0, const char * * argv=0x00f6b428, bool noCalls=false, const char * packageName=0x025d3244, int setFrame=-1) Line 1021 C++
TGEA_DEBUG.exe!CodeBlock::exec(unsigned int ip=1427, const char * functionName=0x024be468, Namespace * thisNamespace=0x00000000, unsigned int argc=0, const char * * argv=0x00000000, bool noCalls=false, const char * packageName=0x00000000, int setFrame=-1) Line 1021 C++
TGEA_DEBUG.exe!CodeBlock::compileExec(const char * fileName=0x024be468, const char * inString=0x025c4368, bool noCalls=false, int setFrame=-1) Line 577 C++
TGEA_DEBUG.exe!Con::evaluate(const char * string=0x025c4368, bool echo=false, const char * fileName=0x024be468) Line 914 C++
TGEA_DEBUG.exe!runEntryScript(int argc=1, const char * * argv=0x02094940) Line 334 + 0x3a bytes C++
TGEA_DEBUG.exe!initGame(int argc=1, const char * * argv=0x02094940) Line 422 + 0xd bytes C++
TGEA_DEBUG.exe!DemoGame::main(int argc=1, const char * * argv=0x02094940) Line 502 + 0xd bytes C++
TGEA_DEBUG.exe!run(int argc=1, const char * * argv=0x02094940) Line 922 + 0x1c bytes C++
TGEA_DEBUG.exe!main(int argc=1, const char * * argv=0x02094940) Line 1000 + 0xd bytes C++
TGEA_DEBUG.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C
TGEA_DEBUG.exe!mainCRTStartup() Line 414 C


Have anyone the same problem running TGEA_DEBUG.exe ????

By internet I found the same problem with similar error Run-Time Check Failure #2 - Stack around the variable 'cz' was corrupted.
:

www.codeguru.com/forum/showthread.php?t=299770

I suppose is the same problem ....... no ?

P.S. The problem is present in TGEA 1.0.1 and TGEA 1.0.3

THANKS
Andrea