// JP opened flex table

Click to See Complete Forum and Search --> : Please help..... heap crash


ElCrasho
March 18th, 2002, 02:17 PM
Hi.

I am running into a crash with VC++ 6.0 service pack 5 and WinXP.

DEBUG MODE :
I get a user breakpoint error :
--------------------------------
HEAP[MyApp.exe]: Heap block at 01E84EA0 modified at 01E84EE8 past requested size of 40
HEAP[MyApp.exe]: Invalid Address specified to RtlFreeHeap( 00350000, 01E84EA8 )
----------------------------------

RELEASE MODE :
It doesnt crash until the app closes and then I get a crash in NTDLL.dll.

I believe this crash may be caused becauseI am trying to access deleted memory. Unfortunately I see no such instance of this happening.

Is there any way I can debug/solve this problem ?? I am loosing my hair stressing over this for the past week :(

thanks in advance.

NigelQ
March 20th, 2002, 10:35 PM
One solution might be to try using NuMega's boundschecker to check your memory usage within the app. I'd highly recommend Boundschecker for this and other types of debugging.

If you don't have the $800 to throw at it, you'll have to track down the problem yourself.

It could be any number of things, like going beyond the end of the last element in an array, or similar problems. I have seen many programmers take the CString memory allocation for granted, only to have it bite 'em in the *** later (me too on occasion)...

When you make one CString equal another, internally, the characters themselves are not copied as you might think, instead the clone creates a pointer to the original, and increases the original's counter.

Now that sounds nice and efficient, but what if you make your global (for example - I know globals are evil) CString equal to a CString in a local routine ? Oops - as soon as the local one goes out of scope, the global one is screwed.

Now, this might not be your problem, but it could be, and if so could take a long time to track down if you're not aware of the above 'feature'.

One solution is to force the compiler to extract the string during the copy, as shown here:

g_MyString = LocalString; // possible problem ?
g_MyString = (LPCTSTR)LocalString; // ...not now :-)



Hope this helps,

- Nigel

//JP added flex table