C++: how to debug a "General Protection Exception"?
i've faced an unhandled exception of "General Protection Exception". while the program runs but there is no output.
i wanted to know what are gen开发者_如何学Goeral efforts i can do to debug such an Exception?
thanks
Yes, if you cannot catch the problem using the debugger in Visual C++ (Professional or Express), and if it is indeed crashing the entire system, take a look at:
http://support.microsoft.com/kb/315263
If it does not crash the system, and the debugger is not getting you to the point of where it occurs, you can try using OutputDebugString and WinDbg:
http://msdn.microsoft.com/en-us/library/aa363362%28VS.85%29.aspx
http://www.microsoft.com/whdc/devtools/debugging/default.mspx
to narrow down which line causes the problem by doing a binary search with two output strings to see where the crash occurs. Eventually you should see your first line print and the second one not print, and then you know the problem may have occurred between the two output strings. You can then move them around logically (in a binary search pattern) until you get them surrounding a single line of code and only the first one prints and then you can suspect the line of actual code between them.
Try using debug diags from msft. This will run a service that will monitor your app and will create a userdump when you get the gpe. You can then load the dump into windbg and see what was happening when the exception happened.
精彩评论