Save a Memory Dump for debugging Crashes: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(Enable Memory Dumps: simplification (no need to scare ppl away with unnecessary trash))
(Moved alternative approach to the very bottom to avoid scaring readers.)
Line 4: Line 4:
If a crash is reproducible, it might be enough to describe the exact steps that lead up to the fault and file a bug report on the [http://bugs.thedarkmod.com bugtracker]. <br>  
If a crash is reproducible, it might be enough to describe the exact steps that lead up to the fault and file a bug report on the [http://bugs.thedarkmod.com bugtracker]. <br>  
But more often than sometimes crashes occur out of seemingly nothing and are barely reproducible, and in this case a saved memory dump is even more valuable for debugging purposes.
But more often than sometimes crashes occur out of seemingly nothing and are barely reproducible, and in this case a saved memory dump is even more valuable for debugging purposes.
<br>
 
In principle, recording memory dumps is not limited to crashed applications.<br>
In principle, recording memory dumps is not limited to crashed applications.<br>
It is possible to record memory dump of alive process, although in most cases such dump would be useless.<br>
It is possible to record memory dump of alive process, although in most cases such dump would be useless.<br>
<br>
 
There a several methods to record a memory dump:
* Record the memory dump manually, when the application is crashing. (see following chapter)
* Record the memory dump automatically, when the application is crashing. (see chapter: "Alternative approach" on this article)
<br>
<b>Note:</b>
<b>Note:</b>
* At the moment this only applies to the Windows OS.<br>
* At the moment this only applies to the Windows OS.<br>
* There is similar mechanism (core dumps) on Linux environments, but it is not covered by this article yet.
* There is similar mechanism (core dumps) on Linux environments, but it is not covered by this article yet.
<br>


== Enable Memory Dumps ==
== Enable Memory Dumps ==
Line 45: Line 40:
<br>
<br>


== Enable and record Memory Dumps automatically (alternative approach) ==
== Compress and upload the dump ==


It is possible to enable automatic saving of crash dumps, when particular program crashes<br>
Depending on what you had opened in DarkRadiant or what FM you loaded in the game itself, the .dmp file might end up very large,<br>
The process is also described in [https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps Windows User-Mode Dumps].
so it's best to compress it by right-clicking it and selecting "Send to..." > "Compressed (zip) folder". <br>(Or use 7-zip to compress the file)<br>
Upload that folder to some place in the web, and please go to the forums to tell the devs about your crash dump.
<br><br>
'''Thanks for your time''',<br>we know that recording and uploading crash dumps might be tedious, <br> but without we really can't do much about the crash, so your help is appreciated!
 
== Debugging / Analysis ==
Coders might want to check out the article on [[Analyze_a_Memory_Dump|analyzing a memory dump.]]
 
 
== Record Memory Dumps automatically (alternative approach) ==
 
It is possible to enable automatic saving of crash dumps, when particular program crashes.<br>
This way is not recommended since it is more complicated.<br>
It is also described in [https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps Windows User-Mode Dumps].


# Press Windows-key + R, type in "cmd", and press Ctrl+Shift+Enter to run it with admin rights.
# Press Windows-key + R, type in "cmd", and press Ctrl+Shift+Enter to run it with admin rights.
Line 71: Line 79:
Alternatively, you can add/remove registry keys directly in Registry Editor if you like.
Alternatively, you can add/remove registry keys directly in Registry Editor if you like.
In this case, restart Windows instead of starting WerSvc service.<br>
In this case, restart Windows instead of starting WerSvc service.<br>
== Compress and upload the dump ==
Depending on what you had opened in DarkRadiant or what FM you loaded in the game itself, the .dmp file might end up very large,<br>
so it's best to compress it by right-clicking it and selecting "Send to..." > "Compressed (zip) folder". <br>(Or use 7-zip to compress the file)<br>
Upload that folder to some place in the web, and please go to the forums to tell the devs about your crash dump.
<br><br>
'''Thanks for your time''',<br>we know that recording and uploading crash dumps might be tedious, <br> but without we really can't do much about the crash, so your help is appreciated!
== Debugging / Analysis ==
Coders might want to check out the article on [[Analyze_a_Memory_Dump|analyzing a memory dump.]]





Revision as of 14:19, 22 January 2022

DarkRadiant or TheDarkMod crashed? If you don't want that to happen again, you need to help the team to debug this malfunction
You can do this by dumping process memory to a file, which can then be used by developers to debug and inspect the application's state at the point in time it crashed.

If a crash is reproducible, it might be enough to describe the exact steps that lead up to the fault and file a bug report on the bugtracker.
But more often than sometimes crashes occur out of seemingly nothing and are barely reproducible, and in this case a saved memory dump is even more valuable for debugging purposes.

In principle, recording memory dumps is not limited to crashed applications.
It is possible to record memory dump of alive process, although in most cases such dump would be useless.

Note:

  • At the moment this only applies to the Windows OS.
  • There is similar mechanism (core dumps) on Linux environments, but it is not covered by this article yet.

Enable Memory Dumps

When application crashes, it usually shows a dialog like this:

Dr has stopped working.png

If you don't get that window showing up for you, please check the WER flag in registry editor:

  • Run the Registry Editor
  • Find path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting
  • Create DWORD key with name DontShowUI and value 0

See alternative method here: https://superuser.com/a/1349113

Record Memory Dumps

  1. When the dialog appears, keep that window open, don't close that dialog, instead open your Task Manager.
    To open the Task Manager, press Ctrl + Shift + Escape.
    Another way is to hit Windows + R and type "taskmgr" and click OK.
  2. In the Task Manager, switch to the Processes tab and locate the program which crashed (DarkRadiant.exe, TheDarkModx64.exe or tdm_installer.exe).
    It should be in that list since you still have the "XXX has stopped working" dialog open in the background.
  3. Now right-click the line with the name of the crashed program and select "Create dump file":
  4. It will work a bit and then show you something like this: "The file has been sucessfully created. The file is located at: location"
  5. Open Windows Explorer and head to the location indicated in the dialog.
    Note that you can mark and copy the location from that dialog using your mouse, so you don't have to type it in entirely.


Dr process in task manager.png

Dr process create dump.png

Dr dump created.png

Compress and upload the dump

Depending on what you had opened in DarkRadiant or what FM you loaded in the game itself, the .dmp file might end up very large,
so it's best to compress it by right-clicking it and selecting "Send to..." > "Compressed (zip) folder".
(Or use 7-zip to compress the file)
Upload that folder to some place in the web, and please go to the forums to tell the devs about your crash dump.

Thanks for your time,
we know that recording and uploading crash dumps might be tedious,
but without we really can't do much about the crash, so your help is appreciated!

Debugging / Analysis

Coders might want to check out the article on analyzing a memory dump.


Record Memory Dumps automatically (alternative approach)

It is possible to enable automatic saving of crash dumps, when particular program crashes.
This way is not recommended since it is more complicated.
It is also described in Windows User-Mode Dumps.

  1. Press Windows-key + R, type in "cmd", and press Ctrl+Shift+Enter to run it with admin rights.
  2. A black window of console will appear. Check the title bar and make sure it is running with administrator rights.
  3. Execute the following commands in the console (copy/paste them with Ctrl+C / Ctrl+V):
  4. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_SZ /v "DumpFolder" /d "c:\temp\CrashDumps"
  5. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "DumpCount" /d "0x1"
  6. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "DumpType" /d "0x2"
  7. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "CustomDumpFlags" /d "0"
  8. net start WerSvc
    (if there is a windows service named "Windows Error Reporting Service")
  9. Close the console, you don't need it anymore.


Now you can run TDM as usual (run executable TheDarkModx64.exe).
If it crashes, a dump will be recorded and saved at C:\temp\CrashDumps.

After this you need to disable automatic saving of memory dumps for TheDarkModx64.exe:

  1. Press Windows-key + R, type in "cmd", and press Ctrl+Shift+Enter to run it with admin rights.
  2. A black window of console will appear. Check the title bar and make sure it is running with administrator rights.
  3. Execute the following commands in the console (copy/paste them with Ctrl+C / Ctrl+V):
  4. reg delete "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe"


Alternatively, you can add/remove registry keys directly in Registry Editor if you like. In this case, restart Windows instead of starting WerSvc service.