Valgrind: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
No edit summary
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Valgrind is especially useful in debugging glibc errors. Errors beginning with <tt>*** glibc detected ***</tt> are errors in Amanda memory allocation detected by glibc. Please report all such problems to the [http://www.amanda.org/support/mailinglists.php amanda-hackers mailing list] or the [http://forums.zmanda.com Amanda forums].
You can disable glibc error detection by setting <tt>$MALLOC_CHECK</tt> to 1. Please note that this might cause Amanda to fail later.
== Amanda installation changes==
== Amanda installation changes==
* Since valgrind don't support suexec program, the easiest way to run valgrind
* Since valgrind don't support suexec program, the easiest way to run valgrind is to configure amanda with '--with-user=root'
is to configure amanda with '--with-user=root'
   ./configure --with-user=root ...
   ./configure --with-user=root ...
   make
   make
Line 8: Line 11:
* Remove all setuid bit
* Remove all setuid bit
   cd /install/path
   cd /install/path
   chmod u-s sbin/amcheck libexec/amcheck libexec/planner libexec/dumper libexec/runtar libexec/rundump
   chmod u-s sbin/amcheck libexec/amcheck libexec/planner libexec/dumper \
    libexec/runtar libexec/rundump


* Changes to [[amanda.conf]]
* Changes to {{man|5|amanda.conf}}
   dumpuser "root"
   dumpuser "root"


Line 31: Line 35:


Example: Following command line creates /tmp/xx.* file for each process:
Example: Following command line creates /tmp/xx.* file for each process:
   valgrind --log-file=/tmp/xx --num-callers=20 --leak-check=yes --leak-resolution=high --freelist-vol=100000000 --trace-children=yes
   valgrind --log-file=/tmp/xx --num-callers=20 --leak-check=yes \
  --leak-resolution=high --freelist-vol=100000000 --trace-children=yes


===Amanda client===
===Amanda client===
Line 38: Line 43:
change to /etc/xinit.d/amanda
change to /etc/xinit.d/amanda
     server      = /usr/bin/valgrind
     server      = /usr/bin/valgrind
     server_args = --log-file=/tmp/yy --num-callers=20 --leak-check=yes --leak-resolution=high --trace-children=yes /path/to/amandad -auth=YOUR-AUTH amdump amindexd amidxtaped
     server_args = --log-file=/tmp/yy --num-callers=20 --leak-check=yes \
                  --leak-resolution=high --trace-children=yes /path/to/amandad \
                  -auth=YOUR-AUTH amdump amindexd amidxtaped


==== rsh authentication ===
==== rsh authentication ====
In common-src/rsh-security.c (around line 248) Add
In common-src/rsh-security.c (around line 248) Add
         "valgrind", "--log-file=/tmp/xx", "--num-callers=20", "--leak-check=yes", "--leak-resolution=high", "--trace-children=yes"
         "valgrind", "--log-file=/tmp/xx", "--num-callers=20", "--leak-check=yes", "--leak-resolution=high", "--trace-children=yes"
between rc-hostname and xamandad_path of the execlp call.
between rc-hostname and xamandad_path of the execlp call.


=== ssh authentication ===
==== ssh authentication ====
In common-src/ssh-security.c (around line 260 and 265 - 2 places) Add
In common-src/ssh-security.c (around line 260 and 265 - 2 places) Add
   "valgrind", "--log-file=/tmp/xx", "--num-callers=20", "--leak-check=yes", "--leak-resolution=high", "--trace-children=yes"
   "valgrind", "--log-file=/tmp/xx", "--num-callers=20", "--leak-check=yes", "--leak-resolution=high", "--trace-children=yes"
between rc-hostname and xamandad_path of the execlp call.
between rc-hostname and xamandad_path of the execlp call.

Latest revision as of 23:55, 30 June 2008

Valgrind is especially useful in debugging glibc errors. Errors beginning with *** glibc detected *** are errors in Amanda memory allocation detected by glibc. Please report all such problems to the amanda-hackers mailing list or the Amanda forums.

You can disable glibc error detection by setting $MALLOC_CHECK to 1. Please note that this might cause Amanda to fail later.

Amanda installation changes

  • Since valgrind don't support suexec program, the easiest way to run valgrind is to configure amanda with '--with-user=root'
 ./configure --with-user=root ...
 make
 make install
  • Remove all setuid bit
 cd /install/path
 chmod u-s sbin/amcheck libexec/amcheck libexec/planner libexec/dumper \
   libexec/runtar libexec/rundump
 dumpuser "root"
  • Changes to /etc/xinit.d/amanda
 user = root
  • Create a /root/.amandahosts with the line
 Amandaserver.FQDN root amdump amindexd amidxtaped
Running Amanda as superuser is not recommended.

Using valgrind

Amanda server

Simply prefix all your command with "valgrind "

 valgrind /path/to/amcheck <config>

This will simply analyze the program, not it's child.

For amdump you need --trace-children=yes

 valgrind --trace-children=yes /path/to/amdump <config>

Example: Following command line creates /tmp/xx.* file for each process:

 valgrind --log-file=/tmp/xx --num-callers=20 --leak-check=yes \
  --leak-resolution=high --freelist-vol=100000000 --trace-children=yes

Amanda client

bsd, bsdudp, bsdtcp authentication

change to /etc/xinit.d/amanda

   server      = /usr/bin/valgrind
   server_args = --log-file=/tmp/yy --num-callers=20 --leak-check=yes \
                 --leak-resolution=high --trace-children=yes /path/to/amandad \
                  -auth=YOUR-AUTH amdump amindexd amidxtaped

rsh authentication

In common-src/rsh-security.c (around line 248) Add

       "valgrind", "--log-file=/tmp/xx", "--num-callers=20", "--leak-check=yes", "--leak-resolution=high", "--trace-children=yes"

between rc-hostname and xamandad_path of the execlp call.

ssh authentication

In common-src/ssh-security.c (around line 260 and 265 - 2 places) Add

 "valgrind", "--log-file=/tmp/xx", "--num-callers=20", "--leak-check=yes", "--leak-resolution=high", "--trace-children=yes"

between rc-hostname and xamandad_path of the execlp call.