Members - Reputation: 122
Posted 07 January 2000 - 01:45 PM
Senior Staff - Reputation: 1361
Posted 07 January 2000 - 06:31 PM
Members - Reputation: 739
Posted 07 January 2000 - 10:00 PM
Well, this is hard without being able to see the actual assertion failures... but here''s some info...
dgbheap.c is responsible for allocating the heap for the debugger. That would be why you don''t see it in release mode. It''s a lot more protective of memory than release is (release would cheerfully let you write over memory used by other applications, if you asked nicely). Check all of your incoming streams, be they tcp/ip or udp coming in, files being read, user input, whatever, and make sure you have enough space allocated to get them. That''s why some of the errors like this are so elusive... you don''t always have too long of a stream... check for buffer overflows.
dgbdel.c is responsible for deleting globals for the debugger. Check your globals. Don''t delete anything you didn''t new.
dbgheap.c(1039) assertion usually means that you tried to free a client block. Don''t do that.
If none of these are the problem, you might want to go ahead and delete all .obj, .exe, and .lib files you have created and try a rebuild all... don''t trust the VC "clean", do it by hand. You can also try reinstalling Windows and/or Visual Studio if you think your libraries might have gotten corrupted (it happens.)
Also, make sure you''re doing regular scans of your disk, I''ve been called in to help a friend with driver problems only to realize their armature has fallen on their hard drive and their disk is quite literally being smoked (barely got the data off in time. we were lucky.) Windows has a scheduler for scanning. Use it.
Members - Reputation: 123
Posted 08 January 2000 - 03:33 AM
Original post by logistix
And no, I do have a winMain() function.
I don''t know what''s going on. I have an app that works fine when compiled in release mode, but when I compile in debug mode I get ASSERT errors that eventually crash the program.
But the ASSERT errors all refer to dbgheap.c and dbgdelete.c which are MS library functions. I can''t get any indication of what part of my code is causing this to happen.
Well for starters if I were in your situation the very first thing I would do is this:
POINT AND CLICK ANSWER:
When you get the ASSERT failure choose the RETRY option to go into debug mode and then >>unwind<< your callstack. What is happening, at least from what I am gathering from your post, is that you are being thrown into the debugger mode at the point the assertion is called, not what led up to the assertion.
WHY AND HOW ANSWER:
A similar situation is when you compile for the first time and forget a ; and you get a billion errors. Now we all know that your don''t start from the end of your output window to see where the compliation went wrong, your start from the beginning. Same basic rules apply when debugging your assertion.
So to sum this up:
Look up your CALLSTACK window option and use it. (it''s pretty neat, and pretty simple to use -- see your help file)
Start using ASSERT and/or VERIFY macro''s in your MSVC source builds and throw the assertion before the fact, not after (preferred)
OFF TOPIC BUT RELATED TO ALL POST:
From one bit pusher to another -- this isn''t a patronizing post. If you feel insulted then by all means ignore this. If you already know this, again, ignore the post. If it helps, great, don''t ignore the post.
Don''t flame me for tyring to be helpful, however, if I am giving ass-backwards advice, then by all means let the flames begin, or better yet, educate us all.
Members - Reputation: 122
Posted 08 January 2000 - 10:08 AM
I knew I was doing a bad delete, I just couldn't figure out how to tell what function was calling it. I was searching the Debug... menu and even trying to hold my mouse over the var hoping a tooltip showing what it referenced would pop up VB style. Leave it to Microsoft to put that not only on the View... menu but on the View... Debug Windows... menu!
I'm the worst debugger. Forget about ASSERT or try...catch. My debugging consists mostly of MessageBox(NULL, "GOT THIS FAR", NULL, NULL);
And in case anyone is interested, here's the problem:
I've got a struct with some pointers to arrays of data that gets saved to a file format. I went to load the file format, checked to see if the pointers were NULL, and DELETE if so. Unfortunately I did this after I loaded in the base struct, which in turn loaded in garbage pointers left over from when it was saved (like it should) which of course weren't equal to NULL.
So I just moved the deletes to the top of the function.
Edited by - logistix on 1/8/00 4:10:01 PM