Save a Memory Dump for debugging Crashes: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Freyk (talk | contribs)
Freyk (talk | contribs)
Line 53: Line 53:
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_SZ /v "DumpFolder" /d "%LOCALAPPDATA%\CrashDumps"
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_SZ /v "DumpFolder" /d "%LOCALAPPDATA%\CrashDumps"
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "DumpCount" /d "0x1"
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "DumpCount" /d "0x1"
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "DumpType" /d "0x1"
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "DumpType" /d "0x1" <br>(you can change dumptype. for "0x1" (minu-dump) or "0x2" (for a full dump)
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "CustomDumpFlags" /d "0"
#reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "CustomDumpFlags" /d "0"
(you can change dumptype. for "0x1" (minu-dump) or "0x2" (for a full dump)
#Then close the black window and restart windows.
#The close the black window and restart windows.
#Run TDM. If TDM then crashes, a dump will be recorded and placed in %LOCALAPPDATA%\CrashDumps.
#Run TDM. If TDM then crashes, a dump will be recorded and placed in %LOCALAPPDATA%\CrashDumps.
#After getting a crashdump, disable the memorydump setting, by change "DumpCount" value to "0" (or to 1)
#After getting a crashdump, disable the memorydump setting, by change "DumpCount" value to "0" (or to 1)

Revision as of 11:04, 3 October 2021

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, we don't know if there's something similar available for Linux environments.

Record the Dump (method 1)

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

Note: If you don't get that window showing up for you (e.g. Windows 10), you'll probably need to re-enable that fix to make it show up again: https://superuser.com/a/1349113

When it 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. In the Task Manager, switch to the Processes tab and locate the program which crashed (DarkRadiant.exe, TheDarkModx64.exe or tdm_update.exe). It should be in that list since you still have the "XXX has stopped working" dialog open in the background.

Now right-click the DarkRadiant.exe line and select "Create dump file":

It will work a bit and then show you something like this:

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.

Record the Dump (method 2)


Most of the time when TDM chrashes, it just stops.
So then it is impossible to record a memorydump when the executable still "runs", using the taskmanager,
But you can also use set a setting in Windows Registry, allowing that windows automatically creates a dump when the TDM executable crashes.
This by enabling "windows User-Mode Dumps".

  1. window start > search for "regedit" and run the app. (or start file explorer > navigate to tdm folder, then in de menu file > open powershell, in de blue window, fill in the following command and hit the enter-key: regedit
  2. On the navigation secion (left side), select Computer > HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows > Windows Error Reporting
  3. Rightclick on that folder > new > key. Call it "LocalDumps"
  4. in the localdumps folder, rightclick in a empty space, new > string. name "DumpFolder", and value "%LOCALAPPDATA%\CrashDumps"
  5. in the localdumps folder, rightclick in a empty space, new > dword32. name "DumpCount", and value "1" (decimal)
  6. in the localdumps folder, rightclick in a empty space, new > dword32. name "DumpType", and value "2" (decimal), or value "1"
  7. in the localdumps folder, rightclick in a empty space, new > dword32. name "CustomDumpFlags", and value "0"
  8. close application and restart windows.
  9. Run TDM. If TDM then crashes, a dump will be recorded and placed in %LOCALAPPDATA%\CrashDumps.
  10. After getting a crashdump, disable the memorydump setting, by change "DumpCount" value to "0" (or to 1)
  11. end.


or
Setting the same thing in the registry, using run the following commands in cmd using administration rights

  1. hit windowskey+r, run command: cmd
  2. a blackscreen will apear and the following commands in. for every command, type the command in and hit the enter-key.
  3. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_SZ /v "DumpFolder" /d "%LOCALAPPDATA%\CrashDumps"
  4. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "DumpCount" /d "0x1"
  5. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "DumpType" /d "0x1"
    (you can change dumptype. for "0x1" (minu-dump) or "0x2" (for a full dump)
  6. reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /t REG_DWORD /v "CustomDumpFlags" /d "0"
  7. Then close the black window and restart windows.
  8. Run TDM. If TDM then crashes, a dump will be recorded and placed in %LOCALAPPDATA%\CrashDumps.
  9. After getting a crashdump, disable the memorydump setting, by change "DumpCount" value to "0" (or to 1)
  10. end.

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 now using 7-zip or by right-clicking it and selecting "Send to..." > "Compressed (zip) folder".

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.