Backtrace

This document is intended to provide information on how to obtain the backtraces required on the asterisk bug tracker, available at http://bugs.digium.com. The information is required by developers to help fix problem with bugs of any kind. Backtraces provide information about what was wrong when a program crashed; in our case, Asterisk. There are two kind of backtraces (aka 'bt') which are useful: bt and bt full.

First of all, when you start Asterisk, you MUST start it with option -g. This tells Asterisk to produce a core file if it crashes.

If you start Asterisk with the safe_asterisk script, it automatically starts using the option -g.

If you're not sure if Asterisk is running with the -g option, type the following command in your shell:

The interesting information is located in the last column.

Second, your copy of Asterisk must have been built without optimization or the backtrace will be (nearly) unusable. This can be done by selecting the 'DONT_OPTIMIZE' option in the Compiler Flags submenu in the 'make menuselect' tree before building Asterisk.

After Asterisk crashes, a core file will be "dumped" in your /tmp/ directory. To make sure it's really there, you can just type the following command in your shell:

In the event that there are multiple core files present (as in the above example), it is important to look at the file timestamps in order to determine which one you really intend to look at.

Now that we've verified the core file has been written to disk, the final part is to extract 'bt' from the core file. Core files are pretty big, don't be scared, it's normal.

NOTE: Don't attach core files on the bug tracker, we only need the bt and bt full.

For extraction, we use a really nice tool, called gdb. To verify that you have gdb installed on your system:

Which is great, we can continue. If you don't have gdb installed, go install gdb.

Now load the core file in gdb, as follows:

Now at the gdb prompt, type: bt You would see output similar to:

The bt's output is the information that we need on the bug tracker.

We also need gdb's output. That output gives more details compared to the simple "bt". So we recommend that you use bt full instead of bt. But, if you could include both, we appreciate that.

The final "extraction" would be to know all traces by all threads. Even if asterisk runs on the same thread for each call, it could have created some new threads.

To make sure we have the correct information, just do: (gdb) thread apply all bt

That output tells us crucial information about each thread.

Now, just create an output.txt file and dump your "bt full" (and/or "bt") ALONG WITH "thread apply all bt" into it.

Note: Please ATTACH your output, DO NOT paste it as a note.

And you're ready for upload on the bug tracker.

If you have questions or comments regarding this documentation, feel free to pass by the #asterisk-bugs channel on irc.freenode.net.

lmadsen 2010-01-14