[Bro] Memory leak output

Siwek, Jon jsiwek at illinois.edu
Tue Feb 3 10:17:16 PST 2015


> On Feb 3, 2015, at 11:43 AM, Josh Liburdi <liburdi.joshua at gmail.com> wrote:
> 
> Wow, thanks Jon-- that helped a lot. When you test with perftools, do
> you do anything different aside from change the configure options
> (--enable-debug --enable-perftools-debug) and run without valgrind?

Here’s an example w/ gperftools:

$ git clone --recursive git://git.bro.org/bro bro-tmp
$ cd bro-tmp
$ ./configure --enable-debug --enable-perftools-debug
$ cd build/
$ vim ../src/Net.cc

$ git diff
diff --git a/src/Net.cc b/src/Net.cc
index adac9c0..53169d2 100644
--- a/src/Net.cc
+++ b/src/Net.cc
@@ -297,6 +297,7 @@ void net_run()
        while ( iosource_mgr->Size() ||
                (BifConst::exit_only_after_terminate && ! terminating) )
                {
+               char* leak = new char;
                double ts;
                iosource::IOSource* src = iosource_mgr->FindSoonest(&ts);

$ make -j8
$ . bro-path-dev.sh
$ HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local ./src/bro -m -r ../testing/btest/Traces/http/get.trace 

WARNING: Perftools heap leak checker is active -- Performance may suffer
Have memory regions w/o callers: might report false leaks
Leak check net_run detected leaks of 23 bytes in 23 objects
The 1 largest leaks:
Leak of 23 bytes in 23 objects allocated from:
	@ 785d25 
	@ 6d61d2 
	@ 3fb601ed5d 
	@ 6b2359 

If the preceding stack traces are not enough to find the leaks, try running THIS shell command:

pprof ./src/bro "./bro.25523.net_run-end.heap" --inuse_objects --lines --heapcheck  --edgefraction=1e-10 --nodefraction=1e-10 --gv

If you are still puzzled about why the leaks are there, try rerunning this program with HEAP_CHECK_TEST_POINTER_ALIGNMENT=1 and/or with HEAP_CHECK_MAX_POINTER_OFFSET=-1
If the leak report occurs in a small fraction of runs, try running with TCMALLOC_MAX_FREE_QUEUE_SIZE of few hundred MB or with TCMALLOC_RECLAIM_MEMORY=false, it might help find leaks more repeatably
Memory leaks - aborting.
Aborted (core dumped)

$ pprof ./src/bro "./bro.25523.net_run-end.heap" --inuse_objects --lines --heapcheck  --edgefraction=1e-10 --nodefraction=1e-10 

Using local file ./src/bro.
Using local file ./bro.25523.net_run-end.heap.
Welcome to pprof!  For help, type 'help'.
(pprof) top
Total: 23 objects
      23 100.0% 100.0%       23 100.0% net_run /home/jsiwek/bro-tmp/src/Net.cc:300
       0   0.0% 100.0%       23 100.0% __libc_start_main ??:0
       0   0.0% 100.0%       23 100.0% _start ??:0
       0   0.0% 100.0%       23 100.0% main /home/jsiwek/bro-tmp/src/main.cc:1200
(pprof) quit





More information about the Bro mailing list