Click to See Complete Forum and Search --> : Debugging program which has complelely 'hung'
robintw
October 23rd, 2006, 08:32 AM
Hi all,
Sorry to ask another question, but I have a strange problem with my code in that it is hanging after I execute a certain event handler. I have put MessageBox::Show's and Debug::Print's in there at strategic points, so I know where it seems to hang. The interesting thing is that sometimes it hangs after the event handler has done everything, but before the final end brace, and sometimes it hangs after the event handler has actually finished executing completely.
The problem is, of course, that I have no idea what code is being run when it hangs - and therefore what is making it hang. Is there any way I can debug this properly? Of course because it hangs I don't get an error message, or an exception, so can't debug the traditional way.
Any ideas anyone?
Robin
wildfrog
October 23rd, 2006, 01:28 PM
When the application is hanging, attach your debugger (Visual Studio etc.) to it and then 'break' the application. You should get at list of the active threads and what the individual thread are currently doing. That may be a start.
- petter
robintw
October 24th, 2006, 02:51 AM
Hi,
I'm running it from within Visual Studio, but when I select Debug->Break, Visual Studio seems to hang for a while, and then eventually displays a message saying "Cannot break the current program" - or something similar to that.
I will try compiling it to an exe, running it separately and then attaching Visual Studio to it and breaking it, and see if that works.
Cheers,
Robin
robintw
October 24th, 2006, 03:02 AM
Hi,
I've just tried that. If I run it as a standalone exe file when it hangs it waits a while and then I get a dialog box saying "PPSSim.exe has encountered a problem and needs to close....". If I do the Attach to Process at this point I get nothing listed in the threads window.
The dialog box does allow me to see the data contained in the error report - but I have no idea how to interpret it! It seems to be a huge memory dump....is it useful at all?
Cheers,
Robin
robintw
October 25th, 2006, 10:23 AM
Hi,
I couldn't seem to stop that program hanging, and in the end I gave up and started that particular part again from scratch.
It's now working ok - thank goodness,
Thanks,
Robin
Feilex
November 5th, 2006, 06:22 PM
Giving up, is sometimes the best option :)
I have worked for 8-10 hours on code, and just erased it, and started over because my thought process wasn't going the right way, or because the errors i was getting were to sever.
wildfrog
November 5th, 2006, 07:27 PM
Giving up, is sometimes the best option ..but, there is always a but. A total rewrite focused on a particular bug often introduce new bugs. And they won't pop up until your application is distributed to numerous customers etc.
The use of source versioning software (Source Safe, CVS etc.) is a good thing when working on 'evolving' software. When a (reproducible) bug appears then you can determine what revision introduced the bug. Let's say that it's not reproducible in version 1.6, but it's present in 1.7, then you can see exactly what changes were made between 1.6 and 1.7 and more easily determine what's causing the bug...
- petter
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.