How can I debug a process started from another process? - debugging

I have a hub application that is responsible for handling the launching of three other programs. I am having considerable difficulty with this - When I launch one of the three alone, everything is fine; when I try to run them from the main hub application, they crash.
I need to figure out how I can keep the hub open, and open the process I start with the debugger after it launches right off, so I can catch the issues and debug it properly.
To give an example for how I am starting the processes from the main program -
this.Hide( );
Process.Start( FilePath).WaitForExit( );
Process.GetCurrentProcess( ).Kill( );

Visual Studio has a setup that allows it to debug any application that crashes before calling ExitProcess() and in case the process threw an exception, if the exception is not caught (i.e. try + catch(...) + exit(1)).
I always let the installer turn on that feature, but if you have it turned off, you should be able to turn it back on by going in the settings. Once one, on a crash, you get a message box asking you whether you want to debug the crashing process.

Related

Different crash behaviors in Windows

We have configured WER (Windows Error Reporting) to create dumps every time some applications crash.
It normally works but we have found several scenarios where it does not work. We will take as an example Winword.exe:
On some cases the process simply disappears. No window, no event log, no crash dump. Nothing.
On other cases a window telling you that the application has stopped working appears but automatically the application gets restarted and no crash dump is generated too.
Other times the application ends as expected with the "Application stopped working" and it works normally.
Any idea about why this happens and how to trap these crashes and generate a dump?

directx 11 c++ application in vs 2012 -- full screen crashes after running for a while

Win7 Directx 11 with VS 2012 -- When I let my app run in full screen on my development computer, eventually, the program exits full screen back to windowed, all by itself, and pops up a dialog telling me windows resources are running low. The dialog tells me something about turning off interactive themes or something to that end. When I run the program in release mode on one of our client machines, the app runs fine, does everything it should, but after a while, instead of popping up the dialog about windows resources, I get an exception window with exception 0x40000015 as the error. This only happens if I am in full screen, windowed, it never crashes. Event Viewer shows nothing at all about the crash. Any thoughts?
Thanks in advance. Basically what my app is, is a wrapper graphics library. When it says I am using all the resources, my resource monitor shows that I never went above 20% of memory and the cpu never went above 14%. The 0x40000015 error number is rather general and doesn't exactly point me in any real direction.
This is not related to trying to exit an app in full screen, as that I have the code required to prevent the exception related to that problem.
R
It turned out to be a component issue on the target platform. The ReportLiveDeviceObjects info was helpful and will continue to help down the line.

How to capture exiting of Qt Application when shut down by debugger?

I am developing a GUI application in Qt 4.8.4 with Visual Studio 2010. I need to perform some cleanup work before my application closes so I have reimplemented the QWidget closeEvent in my MainWindow class to capture when the user either clicks X or when they select File->Exit from the menu. That works fine. The problem however is when I am running the application in the VS debugger and I use the debugger to shut down the application the close event doesn't get triggered. I can always just shutdown my application by clicking File->Exit or clicking X but sometimes I forget and shut down the debugger instead so it's really more of an annoyance. Is there a way to capture when the debugger shuts down my application?
Not that I know of.
The logic of it: the debugger is running a sandbox, and when it shuts down, the sandbox gets freed. Your application is running inside that sandbox - so when that sandbox gets freed/closed/destroyed, your app simply vanishes without any cleanup.

How can I automatically catch and restart a crashed process on Windows?

This might be silly. When my process crashes, a WerFault.exe has been launched and I can regain control only after I close this window or kill its task.
I'm looking for a simple way of not letting crashed program show this window or any idea for me to catch this crash.
SEH is not useful, by the way. I'm not sure why. The crash also remains when I use SEH.
Thanks!
Now I'm just figuring out how to avoid this WerFault.exe windows and sometimes csrss.exe window and regain control.
Use the Application Recovery and Restart API to have Windows Error Reporting (WER) restart and recover your app when it crashes. Use RegisterApplicationRestart() to register your intent to be restarted. Use RegisterApplicationRecoveryCallback() to register your intent to save and recover state data.
I have not tried this but this api : WerAddExcludedApplication should disable error raporting: http://msdn.microsoft.com/en-us/library/bb513617%28v=VS.85%29.aspx
As for restarting your app, you could create another background process that will start your main process and monitor how it behaves. If it crashes then restart it.
[edit]
unfortunately this api might not work, as suggested in comments to it - to remove this dialog your will have to FindWindow() and SendMessage(... WM_CLOSE...).

How can I debug a Windows service that crashes?

I have a .NET Windows service that appears to be crashing due to C00000005 (access violation--according to Dr Watson). When I attach the VS debugger to it--whether I build it with or without symbols--the VS debugger just stops when the service crashes, instead of stopping to give me a chance to do any investigation.
Is that to be expected, or am I doing something wrong?
Will using WinDbg let me do something more in real time (obviously, WinDbg lets me do crash dump analysis)?
Thanks!
You should go to the exceptions window (Debug -> Exceptions) and select the Thrown check box for that exception in the Win32 Exceptions. Moreover, pay attention that you are debugging Native Code (see the attached to combo box in the attach to process window.

Resources