While QGIS developers do their best to make every QGIS release as stable as possible, sometimes you may encounter bugs or even crashes. To get them fixed in the future, it is necessary to inform the developers about issues.
This recipe shows you how to perform basic debugging and collect information that will help developers understand the problem better and help to fix it.
As the QGIS development process is very quick, bugs that are present in older versions are very likely already fixed in the latest version. So, it is necessary to ensure that you have the most recent QGIS version. If you use the development version of QGIS (so called "nightly" builds), upgrade to the last available build. If you prefer stable releases, then ensure that you have the latest stable version.

Under Linux, QGIS automatically tries to use gdb to produce a backtrace when crashed.
If you see no backtrace after the crash, this may mean that the possibility to connect debugger to the running processes is disabled in your distribution (for example, Ubuntu after version 10.10). This behavior is controlled by the ptrace_scope sysctl value. If it equals to 1 ptrace calls from external processes are not allowed. A value that equals to 0 allows external processes to examine memory of the other process.
In such cases, to enable a backtrace creation, temporarily open the root shell and execute the following command:
echo 0 > /proc/sys/kernel/yama/ptrace_scope
If you want to enable a backtrace creation permanently, you need to edit the /etc/sysctl.d/10-ptrace.conf file as root, and set the value to 0. Then, run as root to reload sysctl settings, as follows:
sysctl -p
After this, repeat the steps to reproduce the crash, copy the backtrace, and attach it to your bug report or e-mail.
DebugView is a small program for the Windows operating system that allows you to view and save the debug output of programs. With its help, you can easily get the QGIS debug output and add it to your bug report.
To get the debug output with DebugView, follow these steps:
Dbgview.exe.
Also, if QGIS crashes, it produces a minidump file (usually these files are created in your Temp directory and have the tmp.mdmp extension), as shown in the following screenshot:

A backtrace is a summary of program functions that are still active. In other words, it shows all nested functions and calls from the program's start to the crash point. With the help of a backtrace, developers can isolate place where the bug is.
If you have access to computers with different operating systems, it would be good to check whether this error is reproduced in different environments.
Almost all modern computers and laptops have enough performance to run virtual machines. The snapshots feature is available in the most popular virtual machines. You can have a clean and up-to-date system with recent QGIS for testing and debugging purposes.