To create new wiki account, please join us on #znc at freenode and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

Difference between revisions of "Debugging"

From ZNC
Jump to: navigation, search
(Mention how to attach gdb to existing processes)
(Restore Debugging from archive.org - 2016/11/07)
 
(8 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
Steps to do when you think you found a bug:
 
Steps to do when you think you found a bug:
  
* verify the bug exists in the latest version [https://github.com/znc/znc (Git)]
+
* verify the bug exists in the [[Git|latest version]]
 
* report it at [https://github.com/znc/znc/issues Github]
 
* report it at [https://github.com/znc/znc/issues Github]
 
  
 
== Tracing crash bugs ==
 
== Tracing crash bugs ==
Line 20: Line 19:
  
 
<pre>
 
<pre>
gdb ./znc
+
$ gdb znc
handle SIGPIPE nostop
+
(gdb) set logging file /tmp/znc.gdb.log
run -D
+
(gdb) set logging on
 +
(gdb) handle SIGPIPE nostop noprint pass
 +
(gdb) run -D
 
</pre>
 
</pre>
  
Line 28: Line 29:
  
 
<pre>
 
<pre>
gdb ./znc
+
$ gdb
attach pid
+
(gdb) set logging file /tmp/znc.gdb.log
handle SIGPIPE nostop
+
(gdb) set logging on
cont
+
(gdb) gdb ./znc
 +
(gdb) attach pid
 +
(gdb) handle SIGPIPE nostop noprint pass
 +
(gdb) cont
 
</pre>
 
</pre>
  
Line 43: Line 47:
  
 
<pre>
 
<pre>
bt full
+
(gdb) bt full
 +
</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).
 +
 
 +
=== core files ===
 +
 
 +
You can also get the full backtrace from core file if you have core files enabled.
 +
 
 +
First run <pre>ulimit -c unlimited</pre> 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 <pre>gdb znc core</pre> and there
 +
<pre>
 +
(gdb) set logging /tmp/znc.gdb.log
 +
(gdb) set logging on
 +
(gdb) bt full
 +
(gdb) quit
 
</pre>
 
</pre>
 +
 +
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? ===
 
=== Why use --enable-debug? ===
Line 50: Line 72:
 
With this flag <code>bt full</code> shows much more info, which is needed to understand why the crash had happened.
 
With this flag <code>bt full</code> 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.
 
If you're interested in details, search the Web for "debug symbols" or just try with and without.
 +
 +
[[Category:ZNC]]

Latest revision as of 22:31, 21 May 2017

Reporting bugs[edit]

Steps to do when you think you found a bug:

Tracing crash bugs[edit]

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[edit]

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?[edit]

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.