On Thu, 2004-08-19 at 10:50, Jason Haar wrote:
> Linux too. I've seen this on Redhat 8 and Fedora Core 2.
> 
> > Until someone who can reproduce these memory leaks puts the effort in to
> > find the cause, by using a memory bebugger, this issue is unlikely to
> > get resolved.
> 
> Can you give an example of how to do that? Just because I know how to run
> "make", doesn't make me a programmer :-)
> 
> [in fact, I know a lot of (Windows) programmers: none of them know how to
> run debuggers either... ;-)]

First, make sure you are using 0.75.1 (or the latest CVS code), reports
from older versions are likely to be useless.

On Linux, its easy:

1. install valgrind http://valgrind.kde.org/
2. set clamd to run in the Foreground and not to change user away from
root - in clamav.conf uncomment the Foreground option, and comment out
the User option.
3. Run clamd under valgrind:
valgrind --leak-check=yes /usr/local/sbin/clamd > valgrind.out 2>&1

4. Wait for 'leak' to occur.
5. Shut down clamd cleanly, so that valgrind can process the memory
information. Killing clamd will make the whole process worthless.
        a. TCP Sockets: telnet to the TCP port and type 'QUIT'
        b. UNIX Sockets: use the attachment perl script.
                TEST IT BEFORE YOU START IN EARNEST

Send the valgrind.out file to bugs[at]clamav.net

For other systems (Solaris, FreeBSD, etc.) the same methodology applies,
but you'll need to use a different memory debugger. I haven't tested any
yet but, some possible free candidates are:
        Dmalloc - http://dmalloc.com/
        mpatrol - http://www.cbmamiga.demon.co.uk/mpatrol/

-trog

#!/usr/bin/perl

use IO::Socket::UNIX;

my $LocalSocket = "/tmp/clamd";
my $timeout = 15;


if ( ! -e $LocalSocket ) {
    print "It doesn't look like clamd is running.\n";
    exit 0;
}

my $sock = new IO::Socket::UNIX(Type => SOCK_STREAM,
                                Timeout => $timeout,
                                Peer => $LocalSocket );

if (!$sock || $@ ) {
    print "Clamd Not Running\n";
    exit 0;
}

if ( $sock->connected ) { 

    my $err = "";

    # ask clamd to quit
    $sock->send("QUIT");

    # set the $timeout and die with a useful error if
    # clamd isn't responsive
    eval {
        local $SIG{ALRM} = sub { die "timeout\n" };
	alarm($timeout);
        $sock->recv($err, 200);
	alarm(0);
    };
    if ($@) {

    	die unless $@ eq "timeout\n";
        print "Clamd not responding to QUIT request\n";
	exit 0;

    } else { # clamd responded to the request

        print "Clamd qutting!\n";
    }

} else {
    # you should never get here either
    print "Unknown State (Clamd Useless)\n";
    exit 0;
}

$sock->close();
sleep(1);
my $sock = new IO::Socket::UNIX(Type => SOCK_STREAM,
                                Timeout => $timeout,
                                Peer => $LocalSocket );
                                                                                                                     
if (!$sock || $@ ) {
    print "Clamd Has Quit\n";
    exit 0;
}
$sock->close();
sleep(1);
my $sock = new IO::Socket::UNIX(Type => SOCK_STREAM,
                                Timeout => $timeout,
                                Peer => $LocalSocket );
                                                                                                                     
if (!$sock || $@ ) {
    print "Clamd Has Quit\n";
}

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to