Game Development Community

Out of range write in DEBUG build...

by Stefan Beffy Moises · in Torque Game Engine · 05/12/2002 (10:56 pm) · 22 replies

I've got a problem with our DEBUG build - I haven't used it for weeks (only the release version), and now if I try to use it, it compiles fine, but at startup I get the error:
"Out of range write" in core\bitStream.cc at line 179, which is this one:
void BitStream::writeBits(S32 bitCount, const void *bitPtr)
{
   if(!bitCount)
      return;

   if(bitCount + bitNum > maxWriteBitNum)
   {
      error = true;
      AssertFatal(false, "Out of range write");
      return;
   }
Any idea why it only crashes in the DEBUG build?
(Not that I want it to crash in RELEASE, too, though ;-)
So what's the difference between RELEASE and DEBU here?
Thanks for any help!
Page«First 1 2 Next»
#21
03/07/2008 (10:21 am)
Maybe you're writing more than the 2000 bytes?

What happens if you change it to 10000? That should be safe for testing, but, be aware that for every multiple of the MTU you increase it, you're getting exponentially more packet loss (potentially).

The assert there is important.

It means you're trying to write more than is possible to put into the buffer.

Just changing something like a datablock can cause this problem.
#22
01/01/2012 (4:02 pm)
Bumping an old thread because I still can't find the answer. I'm getting the "Out of range write" error in bitstream.cc @ 194, which is this;
void BitStream::writeBits(S32 bitCount, const void *bitPtr)
{
   if(!bitCount)
      return;

   if(bitCount + bitNum > maxWriteBitNum)
   {
      error = true;
      AssertFatal(false, "Out of range write");  //--this is line 194
      return;
   }
   const U8 *ptr = (U8 *) bitPtr;
   U8 *stPtr = dataPtr + (bitNum >> 3);
   U8 *endPtr = dataPtr + ((bitCount + bitNum - 1) >> 3);

   S32 upShift  = bitNum & 0x7;
   S32 downShift= 8 - upShift;
   U8 lastMask  = 0xFF >> (7 - ((bitNum + bitCount - 1) & 0x7));
   U8 startMask = 0xFF >> downShift;

   U8 curB = *ptr++;
   *stPtr = (curB << upShift) | (*stPtr & startMask);

   stPtr++;
   while(stPtr <= endPtr)
   {
      U8 nextB = *ptr++;
      *stPtr++ = (curB >> downShift) | (nextB << upShift);
      curB = nextB;
   }
   *endPtr &= lastMask;

   bitNum += bitCount;
}

I'm using TGE 1.5.2. Any suggestions?

Thanks!
Page«First 1 2 Next»