Skip to content

Generating a backtrace

Frédéric Brière edited this page Sep 13, 2020 · 5 revisions

Generating a backtrace

When dealing with an issue about Twinkle crashing or hanging, the best piece of information you can provide us with is a backtrace.

(Your distribution may have additional information on this subject. For example, the Ubuntu Wiki has an article dedicated to backtraces.)

Providing debug symbols

A useful backtrace requires that debug symbols for Twinkle be available.

  • If you have compiled Twinkle yourself, add -DCMAKE_BUILD_TYPE=Debug to the list of CMake options and recompile.
  • If you are using a package provided by your distribution, install the corresponding debug symbols package. For Debian and its derivatives (such as Ubuntu), this would be twinkle-dbgsym; see the Debian Wiki or the Ubuntu Wiki for more information.

Generating the backtrace

Install the GNU Debugger, also known as GDB (typically packaged as gdb).

In an interactive session

Running Twinkle in a GDB interactive session is the most common method of generating a backtrace, and is best suited if you can easily trigger the bug.

  • Run gdb twinkle
  • Type set logging on
  • Type set pagination off
  • Type handle SIG32 noprint
  • Type run
  • Trigger the bug that makes Twinkle hang or crash
  • If Twinkle is hung, make it crash by pressing CTRL and \
  • Type thread apply all backtrace
  • Type quit (answer y if you are asked to confirm)

You can then provide us with a copy of the gdb.txt file that was created.

(Note that the full option is not recommended by default, as it could result in passwords or other sensitive information to be included in the backtrace.)

From a core dump file

If the previous method is inconvenient for you (typically, if Twinkle crashes infrequently and you don't want to go through all the steps above every time you launch it), you can instead opt to have Twinkle dump its core in the event of a crash.

For this to work, you first have to enable core dumps with ulimit -c unlimited, performed in the shell that Twinkle will be started from. (You could write a small wrapper shell script to automate this before every launch.)

Twinkle can now be launched as usual. If it crashes, it will generate a core dump file in the directory it was launched from. (If it hangs, you can make it crash with kill -9 <PID>.)

At this point:

  • Run gdb twinkle <core-dump-file-location>
  • Type set logging on
  • Type thread apply all backtrace
  • Press c and Enter
  • Type quit (answer y if you are asked to confirm)