To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.
Debugging: Difference between revisions
>Mkaysi Document using core files. |
Restore Debugging from archive.org - 2016/11/07 |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 19: | Line 19: | ||
<pre> | <pre> | ||
set logging /tmp/znc.gdb.log | $ gdb znc | ||
set logging on | (gdb) set logging file /tmp/znc.gdb.log | ||
gdb | (gdb) set logging on | ||
handle SIGPIPE nostop | (gdb) handle SIGPIPE nostop noprint pass | ||
run -D | (gdb) run -D | ||
</pre> | </pre> | ||
Line 29: | Line 29: | ||
<pre> | <pre> | ||
set logging /tmp/znc.gdb.log | $ gdb | ||
set logging on | (gdb) set logging file /tmp/znc.gdb.log | ||
gdb ./znc | (gdb) set logging on | ||
attach pid | (gdb) gdb ./znc | ||
handle SIGPIPE nostop | (gdb) attach pid | ||
cont | (gdb) handle SIGPIPE nostop noprint pass | ||
(gdb) cont | |||
</pre> | </pre> | ||
Line 46: | Line 47: | ||
<pre> | <pre> | ||
bt full | (gdb) bt full | ||
</pre> | </pre> | ||
If you had logging file set and logging enabled, you can find the bt full and everything else in /tmp/znc.gdb.log. You might want to copy it somewhere safe (that doesn't get cleared every boot unlike /tmp) | If you had logging file set and logging enabled, you can find the bt full and everything else in /tmp/znc.gdb.log. You might want to copy it somewhere safe (that doesn't get cleared every boot unlike /tmp). | ||
=== core files === | === core files === | ||
Line 59: | Line 60: | ||
When your ZNC crashes, you should find a file with name "core" in the directory where you ran znc. If you used cron, it is probably located at $HOME. Now run <pre>gdb znc core</pre> and there | When your ZNC crashes, you should find a file with name "core" in the directory where you ran znc. If you used cron, it is probably located at $HOME. Now run <pre>gdb znc core</pre> and there | ||
<pre> | <pre> | ||
set logging /tmp/znc.gdb.log | (gdb) set logging /tmp/znc.gdb.log | ||
set logging on | (gdb) set logging on | ||
bt full | (gdb) bt full | ||
quit | (gdb) quit | ||
</pre> | </pre> | ||
Latest revision as of 22:31, 21 May 2017
Reporting bugs
Steps to do when you think you found a bug:
- verify the bug exists in the latest version
- report it at Github
Tracing crash bugs
Configure your ZNC version with --enable-debug.
./configure --enable-debug --enable-other-things-you-may-want make make install
Then you can run ZNC under gdb:
$ gdb znc (gdb) set logging file /tmp/znc.gdb.log (gdb) set logging on (gdb) handle SIGPIPE nostop noprint pass (gdb) run -D
If znc is already running, you can attach gdb to the already-running instance (where pid is znc's process id):
$ gdb (gdb) set logging file /tmp/znc.gdb.log (gdb) set logging on (gdb) gdb ./znc (gdb) attach pid (gdb) handle SIGPIPE nostop noprint pass (gdb) cont
Now you use ZNC as you would always do and try to make it crash. Once it crashed, gdb will show you something like this:
Program received signal SIGSEGV, Segmentation fault.
Now we can get the useful info. This info, together with an explanation how the bug happened are then very useful to the developers.
(gdb) bt full
If you had logging file set and logging enabled, you can find the bt full and everything else in /tmp/znc.gdb.log. You might want to copy it somewhere safe (that doesn't get cleared every boot unlike /tmp).
core files
You can also get the full backtrace from core file if you have core files enabled.
First run
ulimit -c unlimited
and preferrably add it to your ~/.bashrc or rc of whatever shell you use. When your ZNC crashes, you should find a file with name "core" in the directory where you ran znc. If you used cron, it is probably located at $HOME. Now run
gdb znc core
and there
(gdb) set logging /tmp/znc.gdb.log (gdb) set logging on (gdb) bt full (gdb) quit
Now your full backtrace should be in /tmp/znc.gdb.log and you can send it to the developers. It's also adviced to copy znc.gdb.log to somewhere outside /tmp as /tmp is cleared every boot.
Why use --enable-debug?
With this flag bt full
shows much more info, which is needed to understand why the crash had happened.
If you're interested in details, search the Web for "debug symbols" or just try with and without.