4

I have configured my windows 7 to create mini dump files on crashes but when my application crashed, no dump file was created. The search for answer left me rather confused as to when are dump files created, when windows crashes or my application crashes?

In my case, I am looking for dump file when my application crashes. I receive a typical crash dialog that states:

TheApp Application has stopped working

Windows can check online for a solution to the problem

-> Check online for a solution and close the program

-> Close the program

-> Debug the program

So can I generate dump file for my application when it crashes? I can't produce this bug on development machine so I want to walk back from dump file. Is there any other option to trace the source of bug (to source code)?

Community
  • 1
  • 1
zar
  • 11,361
  • 14
  • 96
  • 178

3 Answers3

5

First of all, there are different places to configure a "create a minidump on crash" setting, which are totally different.

  1. You can configure Windows to create a kernel dump file when Windows crashes, i.e. when a Bluescreen of death (BSOD) occurs. This is done in the following screen on Windows 7:

    Kernel minidump for Windows crashes

  2. You can configure Windows to create a user mode dump file when an application crashes, i.e. instead of the "Windows Error Reporting" dialog which would normally appear. To do so, and you know that in advance, then configure a Registry key called LocalDumps (MSDN). By default, dumps will be created below %LOCALAPPDATA%\CrashDumps and they will have the naming scheme app.exe.<PID>.dmp.

    WER dialog

  3. For the sake of completeness, there might be other triggers. The only sure way to tell is: when the method MiniDumpWriteDump (MSDN) is called.

I'm quite sure that you want option 2 of the above. If you have trouble with it, see whether all the conditions for LocalDump are fulfilled.

The answer given by @antlersoft does not work, for the reasons I have posted in my blog: at the time the dialog is shown, Windows has triggered a breakpoint to stop the application and it has injected a callstack of Windows Error Reporting. All in all, not a good starting point for debugging.

What would work is:

  1. attach a debugger of your choice
  2. press "Go" in the debugger
  3. press the "Debug" button of the WER dialog
  4. confirm the warning about the debugger which is already attached
  5. click "No" when asked to start debugging using the selected debugger

Using Task Manager to create a crash dump is not recommended, since it will not consider the bitness of the application, which may cause trouble later. See ways to create good and useful crash dumps.

Community
  • 1
  • 1
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
  • Very usefull answer; didn't know the LocalDump reg key. – shrike Jun 17 '16 at 22:54
  • Thanks and yes I sure want #2. You help cleared my confusion that if I have `user mode` dump selected, I should indeed expect a mini dump file to be generated automatically. But what would be the name of the dump file and were will it be generated? – zar Jun 20 '16 at 20:21
  • And I did follow up on @antlersoft answer and tested a new dummy application which I deliberately crash and I could in fact generate dump file by right clicking on it in taskbar without attaching debugger. So that approach does seem to work in a simple demo application but I am still investigating the issue on the actual trouble making executable. – zar Jun 20 '16 at 20:23
  • 1
    @zar: dumps will be created below %LOCALAPPDATA%\CrashDumps and they will have the naming scheme app.exe..dmp – Thomas Weller Jun 20 '16 at 20:29
  • @zar: Use [Search everything](https://www.voidtools.com/) if you can't find them. If you configured `DumpFolder`, make sure it's writeable. – Thomas Weller Jun 20 '16 at 20:30
  • @ThomasWeller Yes when I moved the dump file to development machine, I was able to see the stack and it broke at the exception. My application target is 32 bit environment even though development machine itself is 64 bit. I thought it was not going to proceed with dump file because it has at break point waiting for debugger to attach to continue. – zar Jun 20 '16 at 20:33
  • @zar: ok. Maybe I have to re-test and update my blog article. If it's a dump of a demo application, would you mind sharing it, so that I can have a look at it? – Thomas Weller Jun 20 '16 at 20:35
  • @ThomasWeller sure, you want me to upload to OP temporarily is there is another way? – zar Jun 20 '16 at 20:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/115146/discussion-between-thomas-weller-and-zar). – Thomas Weller Jun 20 '16 at 20:42
1

Minidump is created when Windows crashes. It's not intended to application crash.

If you want to debug crashes of your application, you may attach it to a debugger after it is started. Clicking on the "Debug" button when application crashes do the same. You can use the debugger of MS Visual Studio to do that, for example.

See this page for help on attaching a process to MS Visual Studio debugger: https://msdn.microsoft.com/en-us/library/3s68z0b3.aspx

EDIT: following text removed, as this may not work as expected (comment from Thomas)

You can also create a dump file from task manager, however you will still need a debugger to analyze it and, actually I am not sure you will be able to get the dump file at the point application crashes. The best way, if you can, is to debug the process on the target machine by attaching it to debugger either after it is started or when crash occurs.

shrike
  • 4,449
  • 2
  • 22
  • 38
  • The problem is the crash happens in release build on target machine. I could still install debugger but it doesn't happen when I start it from IDE. – zar Jun 17 '16 at 21:33
  • You can attach a file to debugger even if it is started from the command line. Just start the debugger and click "Attach a process", then select the process in the list of running processes. You can also attach it when it has crahsed, by clicking on the "Debug" button. – shrike Jun 17 '16 at 21:35
  • Task manager is not a good choice, since it does not create dumps of the correct bitness. – Thomas Weller Jun 17 '16 at 22:24
  • @shrike: thanks. See [this answer](http://stackoverflow.com/a/24874028/480982) why bitness and other stuff matters. – Thomas Weller Jun 17 '16 at 22:36
  • Based on Thomas Weller answer, the line "It's not intended to application crash." seems incorrect. If the 'startup and recovery' dialog is configured to create user dump files (=small memory dump?), that should be created when application crashes? – zar Jun 21 '16 at 15:43
1

When you get the crash dialog, go to Task Manager, find the process, right click on the process, and select "Create dump file". The dump file is created in the AppData/Local/Temp folder for the user; it will be named %AppData%\Local\Temp\.DMP; if you create multiple it will be -1.DMP, etc. You can move the dump file to your development machine and open it within Visual Studio. Visual Studio will then act as if you had hit "Break all" at the point of the crash while running the process in the debugger.

antlersoft
  • 14,636
  • 4
  • 35
  • 55
  • That sound promising but are you positive it will still create dump file when it just let out a message that it has _stopped_ working and is essentially not responding? :) – zar Jun 17 '16 at 21:41
  • 1
    @zar - The process is still in memory, ready for the debugger to attach, so yes you can create a dump. – antlersoft Jun 17 '16 at 21:43
  • Have you ever done this and in consequence, analyzed the dump? You'll have a hard time with it, since it stops at a breakpoint and not at the exception you want to have. – Thomas Weller Jun 17 '16 at 22:10
  • Task manager is not a good choice, since it does not create dumps of the correct bitness. – Thomas Weller Jun 17 '16 at 22:23
  • So combine your answer with @ThomasWeller, I believe this file might be created automatically since I have already select mini dump files for `user mode`? But I can't find the file in %AppData% folder. There are no files there, just folders. What should be the name of the dump file anyways? – zar Jun 20 '16 at 20:14
  • @zar - They are in %AppData%\Local\Temp\.DMP; if you create multiple it will be -1.DMP, etc. – antlersoft Jun 20 '16 at 20:40
  • One strange thing is my %AppData% translate into the actual %AppData%\Roaming folder which is weird. – zar Jun 20 '16 at 21:10