Archived

This topic is now archived and is closed to further replies.

Crazy Debug Problem

This topic is 4988 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m getting a really weird debugging error. When I run my program, I get an exception that crashes it. The entirety of the call stack is: kernel32.dll!77e73887() kernel32.dll!77e73887() > mainProject.exe!_nh_malloc_dbg(unsigned int nSize=33, int nhFlag=1243664, int nBlockUse=4844985, const char * szFileName=0xe06d7363, int nLine=1) Line 260 + 0x15 C mainProject.exe!malloc(unsigned int nSize=0) Line 139 + 0x15 C Now, I never use malloc(), yet it says that there is a problem there and it doesn''t show me the flow that it got there by, so I up a creek without a paddle right now. FYI, I''m using VS .NET 2003 Academic and C++ as the programming language. Does anybody have any ideas on how I can solve this problem? mmm...Coffee. Nectar of the Gods!

Share this post


Link to post
Share on other sites
Try reducing your program to the minimum that will reproduce the error and posting that code. Or even posting the code without reducing it.

Share this post


Link to post
Share on other sites
In the lower-left hand area of the debugger, there should be a window with tabs at the bottom that say Auto, Locals, and This, and it should be set to Autos by default. That window should also display the variables and function calls involved on the current line that you''ve stepped to. At the top of that window is a combo box with the title Context. If you click on the combo box, you''ll get a list of the function call stack and you can see the line of code where each function was called. So, just run your program through the debugger until it hits the exception and look at the call stack. Note that this is for MSVC 5.0, I don''t know if it''s the same or not for .NET.

Share this post


Link to post
Share on other sites
The vast majority of times when you see something like this it''s because your program has corrupted the heap - i.e. overran a buffer, freed the same memory twice, use memory after it was freed, etc, etc.

There are tools to help you find such problems. Although I use internal ones so don''t know what''s publically available. Other things you can do are to go through your code to try to see a problem. You can sprinkle calls to _heapchk (for VC programs) or just plain malloc to try to find the problem earlier. etc.

Share this post


Link to post
Share on other sites