Crash in memory manager
by Stephen Lujan · in Torque Game Engine · 06/17/2007 (3:25 am) · 5 replies
I was running TGE under MSVC 6 when it crashed with this exception
function static void treeRemove(FreeHeader *hdr)
Leading up to this function "bool ParticleEmitter::prepRenderImage" ran the line
Quote:First-chance exception in torqueDemo_DEBUG.exe: 0xC0000005: Access ViolationThis according to MSVC the crash occurred at line 490 of "engine/platform/platformMemory.cc" in
function static void treeRemove(FreeHeader *hdr)
Leading up to this function "bool ParticleEmitter::prepRenderImage" ran the line
Quote:SceneRenderImage* image = new SceneRenderImage;which called
Quote:void* FN_CDECL operator new(dsize_t size, const char* fileName, const U32 line)which called
Quote:static void* alloc(dsize_t size, bool array, const char* fileName, const U32 line)which called
Quote:static void treeRemove(FreeHeader *hdr)
About the author
#2
06/17/2007 (4:32 am)
The error is rare, I've seen it only a few times, so far it only happens when calling "new SceneRenderImage" sometimes for explosions sometimes for particle emitters. The conditions were not unusual. I was playing on the barebones map letting some ai players fight eachother. I'm going to try disabling the memory manager and seeing what effect it has. Thank you Stefan.
#3
06/17/2007 (7:18 am)
It's not a permanent solution if you want the functions which the memory manager offers, but at least you can move on until you know more about it.
#4
I just posted a fix in the TGEA forums and I think that it is this same issue...
Here is a reprint of my post in that forum for people who don't own TGEA...
Hi,
This one is a bit nasty, as such, I would really appreciate if some of the big guns could take a look at this to verify or refute the fix...
On line 1035 of platformMemory.cpp is the following bit of code:
If TORQUE_DEBUG_GUARD is not set, the code is fine, because the Header structure will take up exactly 16 bytes and we have padded our memory allocation out by 16 bytes.
However, if TORQUE_DEBUG_GUARD is set, then we are only padding by 4 bytes. Even without TORQUE_DEBUG_GUARD, the Header struct is still 16 bytes. With the guard the header grows to 64 bytes at a minimum and 68 bytes if TORQUE_ENABLE_PROFILE_PATH is set.
So, I believe this code should look like this:
It would be very helpful if someone could either verify this fix or explain to me why the current code is correct.
Thanks for the help.
Todd
07/11/2007 (12:50 pm)
Hi guys,I just posted a fix in the TGEA forums and I think that it is this same issue...
Here is a reprint of my post in that forum for people who don't own TGEA...
Hi,
This one is a bit nasty, as such, I would really appreciate if some of the big guns could take a look at this to verify or refute the fix...
On line 1035 of platformMemory.cpp is the following bit of code:
#ifdef TORQUE_DEBUG_GUARD // if we're guarding, round up to the nearest DWORD size = ((size + 3) & ~0x3); #else // round up size to nearest 16 byte boundary (cache lines and all...) size = ((size + 15) & ~0xF); #endif
If TORQUE_DEBUG_GUARD is not set, the code is fine, because the Header structure will take up exactly 16 bytes and we have padded our memory allocation out by 16 bytes.
However, if TORQUE_DEBUG_GUARD is set, then we are only padding by 4 bytes. Even without TORQUE_DEBUG_GUARD, the Header struct is still 16 bytes. With the guard the header grows to 64 bytes at a minimum and 68 bytes if TORQUE_ENABLE_PROFILE_PATH is set.
So, I believe this code should look like this:
#ifdef TORQUE_DEBUG_GUARD
#ifdef TORQUE_ENABLE_PROFILE
size = ((size + 127) & ~0x7F);
#else
size = ((size + 63) & ~0x3F);
#endif
#else
size = ((size + 15) & ~0xF);
#endifIt would be very helpful if someone could either verify this fix or explain to me why the current code is correct.
Thanks for the help.
Todd
#5
Clark helped me in the TGEA forums and my proposed fix is NOT helpful.
Sorry.
Todd
07/11/2007 (10:02 pm)
Disregard my last post.Clark helped me in the TGEA forums and my proposed fix is NOT helpful.
Sorry.
Todd
Torque Owner Stefan Lundmark