Save a Memory Dump for debugging Crashes: Difference between revisions
Cleaning the GDB section |
|||
(51 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
DarkRadiant or TheDarkMod crashed? If you don't want that to happen again, you need to help the team to debug this malfunction | DarkRadiant or TheDarkMod crashed? If you don't want that to happen again, you need to help the team to debug this malfunction <br> | ||
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 [http://bugs.thedarkmod.com 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. | 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. | |||
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. | 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> | |||
= Windows = | |||
== | |||
== Enable Memory Dumps == | |||
When application crashes, it usually shows a dialog like this: | When application crashes, it usually shows a dialog like this: | ||
[[File:Dr has stopped working.png]] | [[File:Dr has stopped working.png]] | ||
<br><br> | |||
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: <tt>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting</tt> | |||
* Create <tt>DWORD</tt> (32bit) key with name <tt>DontShowUI</tt> and value <tt>0</tt> | |||
See alternative method here: https://superuser.com/a/1349113 | |||
== Record Memory Dumps == | |||
# When the dialog appears, keep that window open, '''don't close that dialog''', instead open your Task Manager.<br> To open the Task Manager, press Ctrl + Shift + Escape.<br> 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_installer.exe). <br> It should be in that list since you still have the "XXX has stopped working" dialog open in the background. | |||
# Now right-click the line with the name of the crashed program and select "Create dump file": | |||
# It will work a bit and then show you something like this: "The file has been sucessfully created. The file is located at: location" | |||
# Open Windows Explorer and head to the location indicated in the dialog. <br><b>Note</b> that you can mark and copy the location from that dialog using your mouse, so you don't have to type it in entirely. | |||
<br> | |||
[[File:Dr process in task manager.png]] | [[File:Dr process in task manager.png]] | ||
<br><br> | |||
[[File:Dr process create dump.png]] | |||
<br><br> | |||
[[File:Dr dump created.png]] | |||
<br> | |||
<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.]] | |||
== Record Memory Dumps automatically (alternative approach) == | |||
When the "darkradiant has stopped working" popup doesnt appear, when the program crashes,<br> | |||
<br> | then is possible to enable automatic saving of crash dumps, <br> | ||
<br> | This way is not recommended since it is more complicated to setup.<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. | |||
# A black window of console will appear. Check the title bar and make sure it is running with administrator rights. | |||
# Execute the following commands in the console (copy/paste them with Ctrl+C / Ctrl+V): | |||
# <tt>reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_SZ /v "DumpFolder" /d "c:\temp\CrashDumps"</tt> | |||
# <tt>reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "DumpCount" /d "0x1"</tt> | |||
# <tt>reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "DumpType" /d "0x2"</tt> | |||
# <tt>reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "CustomDumpFlags" /d "0"</tt> | |||
# <tt>net start WerSvc</tt> <br>(if there is a windows service named "Windows Error Reporting Service") | |||
# Close the console, you don't need it anymore. | |||
<br> | <br> | ||
Now you can run TDM as usual (run executable TheDarkModx64.exe).<br> | |||
If it crashes, a dump will be recorded and saved at <tt>C:\temp\CrashDumps</tt>.<br> | |||
<br> | <br> | ||
After this you need to disable automatic saving of memory dumps for TheDarkModx64.exe: | |||
# | # Press Windows-key + R, type in "cmd", and press Ctrl+Shift+Enter to run it with admin rights. | ||
# | # A black window of console will appear. Check the title bar and make sure it is running with administrator rights. | ||
# | # Execute the following commands in the console (copy/paste them with Ctrl+C / Ctrl+V): | ||
# <tt>reg delete "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe"</tt> | |||
#reg | |||
< | |||
<br> | <br> | ||
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> | |||
= Linux = | |||
== Record with GDB == | |||
Make sure GDB is installed. Usually it is installed by default. | |||
[[File:Coredump-_start_gdb.png|thumb]] | |||
[[File:Coredump-_save_core_dump.png|thumb]] | |||
# Run the game under GDB: <tt>gdb ./thedarkmod.x64</tt> | |||
# Within GDB, type <tt>run</tt> and hit Enter to start the program. | |||
# When the game crashes, gdb will most likely break. | |||
# Record core dump with a command: <tt>generate-core-file</tt> | |||
# The dump should be in the current directory, usually named like <tt>core.27372</tt>. | |||
Note that core dumps are pretty large, but they compress well. | |||
Make sure to put it into zip/gz/whatever before uploading. | |||
Unfortunately, sometimes core dump alone is not enough to inspect the crash on the other machine. | |||
A developer might need some system binaries in order to properly decipher stack trace. | |||
The following libraries are known to be necessary sometimes: | |||
* <tt>libc</tt> | |||
* <tt>libpthread</tt> | |||
* <tt>libthread_db</tt> | |||
These files are usually named something like <tt>libpthread-2.26.so</tt>, <tt>libc-2.26.so</tt>, <tt>libthread_db.so.1</tt> and are located in <tt>/lib/x86_64-linux-gnu</tt>. | |||
Beware of symlinks! The developer needs the target file with real contents. | |||
See also: [https://forums.thedarkmod.com/index.php?/topic/21060-mission-downloader-issue "Mission downloader issue" on the forum] | |||
[[Category:DarkRadiant]] | [[Category:DarkRadiant]] | ||
[[Category:Coding]] | [[Category:Coding]] |
Latest revision as of 00:00, 12 April 2025
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.
Windows
Enable Memory Dumps
When application crashes, it usually shows a dialog like this:
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 (32bit) key with name DontShowUI and value 0
See alternative method here: https://superuser.com/a/1349113
Record Memory Dumps
- 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. - 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. - Now right-click the line with the name of the crashed program and select "Create dump file":
- It will work a bit and then show you something like this: "The file has been sucessfully created. The file is located at: location"
- 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.
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)
When the "darkradiant has stopped working" popup doesnt appear, when the program crashes,
then is possible to enable automatic saving of crash dumps,
This way is not recommended since it is more complicated to setup.
It is also described in Windows User-Mode Dumps.
- Press Windows-key + R, type in "cmd", and press Ctrl+Shift+Enter to run it with admin rights.
- A black window of console will appear. Check the title bar and make sure it is running with administrator rights.
- Execute the following commands in the console (copy/paste them with Ctrl+C / Ctrl+V):
- reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_SZ /v "DumpFolder" /d "c:\temp\CrashDumps"
- reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "DumpCount" /d "0x1"
- reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "DumpType" /d "0x2"
- reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\TheDarkModx64.exe" /t REG_DWORD /v "CustomDumpFlags" /d "0"
- net start WerSvc
(if there is a windows service named "Windows Error Reporting Service") - 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:
- Press Windows-key + R, type in "cmd", and press Ctrl+Shift+Enter to run it with admin rights.
- A black window of console will appear. Check the title bar and make sure it is running with administrator rights.
- Execute the following commands in the console (copy/paste them with Ctrl+C / Ctrl+V):
- 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.
Linux
Record with GDB
Make sure GDB is installed. Usually it is installed by default.


- Run the game under GDB: gdb ./thedarkmod.x64
- Within GDB, type run and hit Enter to start the program.
- When the game crashes, gdb will most likely break.
- Record core dump with a command: generate-core-file
- The dump should be in the current directory, usually named like core.27372.
Note that core dumps are pretty large, but they compress well. Make sure to put it into zip/gz/whatever before uploading.
Unfortunately, sometimes core dump alone is not enough to inspect the crash on the other machine. A developer might need some system binaries in order to properly decipher stack trace. The following libraries are known to be necessary sometimes:
- libc
- libpthread
- libthread_db
These files are usually named something like libpthread-2.26.so, libc-2.26.so, libthread_db.so.1 and are located in /lib/x86_64-linux-gnu. Beware of symlinks! The developer needs the target file with real contents.
See also: "Mission downloader issue" on the forum