- 1 Development/Tutorials/Debugging/How to create useful crash reports
- 2 Introduction
- 3 How to create useful crash reports
Development/Tutorials/Debugging/How to create useful crash reports
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
This document describes how to reproduce a useful backtrace of crashing KDE applications. First, some general information is given. Then, we will describe for several distributions how to prepare your KDE packages and gather the backtrace. This should be enough for most people. There are additional sections on how to create backtraces with the GNU Debugger and with Valgrind, which are usefulin some cases.
How to create useful crash reports
A good crash report at KDE Bugzilla consists of two parts: a description of how to reproduce the crash and a backtrace of the crash. With one of those elements missing, it is much harder (if not impossible) for developers to tackle the problem.
A description should consist of more than only "it crashed". Try to describe everything you did prior to the crash. Did you click on a button, opened a particular website or file which caused problems? That little detail which may look useless to you may be useful for the developer, so just write it down.
- The KDE version is an important detail that it is often missing in bug reports. If you do not know what KDE version are you using you can get it using the command kde4-config --version for KDE4 in Konsole (and kde-config --version for KDE3). You will get an output like:
Qt: 4.5.2 KDE: 4.3.0 (KDE 4.3.0) kde4-config: 1.0
A more insightful article on how to write good bug descriptions is available at this link, please read that before reporting bugs.
Application specific details
For several applications it can be useful to have specific details in bug reports:
- Plasma: Plasmoids you have in your desktop (both official and unofficial), desktop settings (wallpaper plugin, themes).
- Konqueror: Sites you were visiting, number of opened tabs, plugins you have installed.
- Dolphin:: file view mode, grouping and sorting settings, preview settings, directory you were browsing.
- Kopete: IM protocols you use.
- KMail: Mail protocols and account-types you use.
- KWrite/Kate/KOffice: Type of the document you were editing.
- Multimedia Players (Juk/Dragon/Amarok): Type of media (extension and format) you were watching/listening to.
Backtraces are essential. They may look meaningless to you, but they might actually contain a wealth of useful information. A backtrace basically describes what was happening inside the application when it crashed, in a way that developers may track down where the mess started.
- Don't attach the backtrace to the bug report. Instead, simply paste it. This way it is much easier for developers to search for duplicate reports, because attachments will not be searched.
Even though pasting backtraces directly is preferred over adding an attachment, please do not paste other things like logs (valgrind, strace or terminal output) or example data (mails, HTML files and so on). Use attachments for these items.
Having good backtraces has a downside: Libraries and executables occupy much more disk space than their optimized counter parts. That's the reason why many distros choose to install stripped files, which results in useless backtraces:
(no debugging symbols found) Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1". (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) [Thread debugging using libthread_db enabled] [New Thread -1233848624 (LWP 12212)] [New Thread -1255081072 (LWP 12820)] [New Thread -1240921200 (LWP 12819)] [New Thread -1266680944 (LWP 12818)] (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) 0xffffe410 in __kernel_vsyscall () #0 0xffffe410 in __kernel_vsyscall () #1 0xb6a1210b in ?? () from /lib/tls/i686/cmov/libpthread.so.0 #2 0xb6a85afe in ?? () from /usr/lib/libX11.so.6 #3 0x00000003 in ?? () #4 0x082149c0 in ?? () #5 0x00003ffc in ?? () #6 0x00000000 in ?? ()
But no worries, with some modifications you can create full blown backtraces for KDE applications.
Preparing your KDE packages
If your distribution has debugging-enabled packages, install them.
It is easy to see which debug packages you are missing from looking at the backtrace. For example, take the following line from a backtrace:
#6 0xb7975bdc in ?? () from /usr/lib/libkmailprivate.so.4
The ?? indicates that the library libkmailprivate.so.4 does not have debug information, which might be available in separate debug packages. In this case, it is pretty easy to guess that you need to install debug packages for KMail to get a better backtrace.
Sometimes, you need to install more than one debug package to get a good backtrace. This depends on how the distribution splits up the packages. For example, for some distributions it is enough to install the debug package for kdepim to get enough debugging information for a crash in KMail, for other distributions there is an additional debug package just for KMail.
Here's a list of how to obtain debug packages for some distributions:
- Debian - Debian offers -dbg packages to easy create useful backtraces. Just install the corresponding -dbg package. e.g. kdepim-dbg for KMail crashes. The dependencies of -dbg makes sure to pull in the other right packages (kdelibs-dbg, gdb, and so on).
- FreeBSD ports - Please refer to the KDE on FreeBSD FAQ.
- Gentoo - Gentoo has its own document describing how to proceed.
- Mandriva - Mandriva 2007.0 and up has additional debugging packages for all of KDE (in fact, for all of its packages). Just install the corresponding -debug package, like kdebase-debug and kdemultimedia-debug. You probably want to install kdelibs-debug anyways.
- Note: the -debug packages are in separate repositories. For instance, for all packages in main, you'll find the debugging package in repository debug_main.
- Kubuntu/Ubuntu - The Ubuntu family makes things quite easy. Every official KDE module has an additional package in the repository, suffixed with -dbg. Always install kdelibs5-dbg, because all KDE applications use kdelibs (kdelibs-dbg for KDE 3 applications). Then you should install a -dbg package for the application which crashed. For example if KOrganizer crashed you should install kdepim-dbg as well. If the program is not from an official KDE module and has no -dbg package, you can install the -dbgsym package from the repository listed on this Debugging Program Crashes page.
- openSUSE - You should only install the -debuginfo packages, for example: kdepimlibs4-debuginfo. You can find these packages in KDE repositories. There is also a dedicated openSUSE debugging page.
- Fedora - Fedora has its own document describing how to proceed. (A debuginfo repository has to be enabled.)
- ArchLinux - If you are using the KDEMod repository you can install the -debug packages for each KDE module. If you are using the standard Arch repositories you need to recompile your packages manually. You will find more help in this article: Debug, Getting Traces
If your distribution doesn't have debugging-enabled packages for KDE, you'll have to compile KDE from sources:
- If you're using KDE 3, then at the configure stage, you should supply the parameter --enable-debug=full in order to build debug symbols in the resulting files.
- If you're using KDE 4, then at the cmake stage, you should supply the parameter -DCMAKE_BUILD_TYPE=debugfull. If you want to specify your own CXXFLAGS, then use -DCMAKE_BUILD_TYPE=None CMAKE_CXX_FLAGS="-O0 -g". You can change the CMAKE_CXX_FLAGS as appropriate for your needs.
Then it's just make and make install as you're used to.
Now it's time to crash your application (reproducing the steps that caused the application to crash the first time).
The KDE Crash Handler Dialog should appear right after the crash:
KDE 4.3 and later
Since KDE 4.3 there is a new version of the crash handler dialog:
In order to get a backtrace directly you need to click the "Developer Information" tab.
KDE 4.0 - 4.2
In order to get the backtrace you need to click the "Show details" checkbox.
In order to get a backtrace you need to click the "Backtrace" tab.
This process may take quite some memory and CPU, so things may go sluggish all of a sudden. But the result should look much better. For example:
Thread 1 (Thread 0x7f3579b39750 (LWP 14011)):
- 5 setCaretInvisibleIfNeeded (part=0x16e2ca0) at
- 6 0x00007f356a8b92b5 in KHTMLPart::setCaretMode (this=0x16e2ca0,
enable=false) at /home/kde-devel/kde/src/KDE/kdelibs/khtml/khtml_part.cpp:2812
- 7 0x00007f356a8c98bd in KHTMLPart::qt_metacall (this=0x16e2ca0,
_c=QMetaObject::InvokeMetaMethod, _id=<value optimized out>, _a=0x7fff81c7a800)
- 8 0x00007f3577276ac0 in QMetaObject::activate (sender=0x1884c90,
from_signal_index=<value optimized out>, to_signal_index=6, argv=0x1cb7f00) at kernel/qobject.cpp:3028
- 9 0x00007f3576612a57 in QAction::triggered (this=0x0, _t1=false) at
- 10 0x00007f3576613204 in QAction::activate (this=0x1884c90, event=<value
optimized out>) at kernel/qaction.cpp:1125
- 11 0x00007f3576616862 in QAction::event (this=0x1884c90, e=0x7fff81c7ad90) at
- 12 0x00007f3577faa503 in KAction::event (this=0x0, event=0x7fff81c7ad90) at
- 13 0x00007f35766180ad in QApplicationPrivate::notify_helper (this=0x10be800,
receiver=0x1884c90, e=0x7fff81c7ad90) at kernel/qapplication.cpp:3803
- 14 0x00007f357661f40e in QApplication::notify (this=0x7fff81c7c510,
receiver=0x1884c90, e=0x7fff81c7ad90) at kernel/qapplication.cpp:3768
- 15 0x00007f357808155b in KApplication::notify (this=0x7fff81c7c510,
receiver=0x1884c90, event=0x7fff81c7ad90) at /home/kde-devel/kde/src/KDE/kdelibs/kdeui/kernel/kapplication.cpp:307
- 16 0x00007f3577261d90 in QCoreApplication::notifyInternal
(this=0x7fff81c7c510, receiver=0x1884c90, event=0x7fff81c7ad90) at
This looks better, right? It shows memory addresses, the source files and line numbers and the parameters passed to functions. Which make it more helpful to the developer where to look for the problem.
Retrieving a backtrace with GDB
In some cases, it is not possible to create a backtrace with the KDE Crash Dialog. This may be caused by an application which entered an infinite loop, or the crash dialog did not appear at all for some reason. You can try to grab a backtrace with gdb, the GNU Debugger. GDB is widely available through distribution packages.
Invoking GDB differs from the situation. You can run an application from inside gdb, or attach gdb to an already running process. The latter may be useful when an application already has entered an infinite loop. But we will first start with running an application inside gdb. From the shell, run:
$ gdb someKDEapp
The GDB prompt will appear. Note that this does not start the application itself, you should run it by invoking the run command:
This will run the application like you are used to, and you can work with it like normal (it only consumes far more memory and may feel sluggish). Now it's time to reproduce your crash. When you succeed, the application just closes and you should return to your GDB prompt. Now it's time to run the 'backtrace' command:
(gdb) thread apply all backtrace
This should give a good backtrace which can be posted at the KDE Bugzilla.
In case you want to attach to an existing process, run the following command in the shell:
$ gdb someKDEapp pid
where pid is the process ID of the process you want to attach to. Once attached, and the process is in an infinite loop, after using the 'backtrace' command again a useful backtrace will appear. You can use 'continue' command to let the application run again and press Ctrl+C in gdb to be able to again enter commands.
Retrieving a backtrace with Valgrind
When it comes to crashes, Valgrind is also a useful tool to create a backtrace. It's not a substitution for GDB, but rather a supplement.
When you run an application in valgrind, every piece of memory read or written by the application is being checked. Valgrind will report erroneous memory operations in the standard output or in a log file. Since most crashes are due to an invalid memory read, valgrind can be useful to track down where the problem occurs.
Like GDB, Valgrind makes running an application much slower, while consuming a lot more resources.
Start the application within valgrind:
$ valgrind --log-file=someKDEapp someKDEapp
Now reproduce the crash. As soon as this happens, the application and valgrind will terminate. What's left is a file named someKDEapp.pid where pid is replaced by the process ID of the valgrind process. The file may list more errors than the one causing the crash. Here's the bit causing the crash which corresponds to the GDB backtrace above:
==23292== Invalid read of size 4 ==23292== at 0x806BD9E: TreeMapItem::parent() const (treemap.h:285) ==23292== by 0x8065FB9: TreeMapItemList::compareItems(void*, void*) (treemap.cpp:720) ==23292== by 0x50AC618: QGList::operator==(QGList const&) const (in /usr/qt/3/lib/libqt-mt.so.3.3.8) ==23292== by 0x806D3BF: QPtrList<TreeMapItem>::operator==(QPtrList<TreeMapItem> const&) const (qptrlist.h:74) ==23292== by 0x8062DE7: TreeMapWidget::mousePressEvent(QMouseEvent*) (treemap.cpp:1840) ==23292== by 0x4E2FA62: QWidget::event(QEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8) ==23292== by 0x4D96CA6: QApplication::internalNotify(QObject*, QEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8) ==23292== by 0x4D97A87: QApplication::notify(QObject*, QEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8) ==23292== by 0x4809AC3: KApplication::notify(QObject*, QEvent*) (kapplication.cpp:550) ==23292== by 0x4D36FD1: QETWidget::translateMouseEvent(_XEvent const*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8) ==23292== by 0x4D368AF: QApplication::x11ProcessEvent(_XEvent*) (in /usr/qt/3/lib/libqt-mt.so.3.3.8) ==23292== by 0x4D46760: QEventLoop::processEvents(unsigned) (in /usr/qt/3/lib/libqt-mt.so.3.3.8) ==23292== Address 0x2C is not stack'd, malloc'd or (recently) free'd
But to be sure, just attach the whole log file to the crash report.