I have a strange situation where the Valgrind output for the exact same executable is different on one machine than it is on another.
I'm writing a windows registry reading/writing library in C++, and I've been trying to be very robust in writing the code. So I've been running Valgrind all along and fixing memory leaks as they're introduced by means of an executable that is generated from a bundle of unit tests.
My main development PC is running Linux Mint Debian Edition x86_64. One weekend, I cloned my repository to my laptop which is running Arch x86_64 and I started getting memory leaks (or rather, still-reachable blocks) showing up in Valgrind. After much hair pulling, I realized that even the last commit that was clean on Mint DE was showing leaks on Arch. I also noticed that the number of allocs is more than quadruple on the Arch box, though I don't know if that means anything.
Here's what I have using the same exe's on both machines (compiled on 1 machine and copied to the other):
Mint DE x86_64:
valgrind --leak-check=full --show-leak-kinds=all ./regnixtest
==12248== Memcheck, a memory error detector
==12248== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==12248== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==12248== Command: ./regnixtest
==12248==
Testing Create Valid NK...passed
[ normal command output snipped for brevity ]
==12248==
==12248== HEAP SUMMARY:
==12248== in use at exit: 0 bytes in 0 blocks
==12248== total heap usage: 603 allocs, 603 frees, 608,657,070 bytes allocated
==12248==
==12248== All heap blocks were freed -- no leaks are possible
==12248==
==12248== For counts of detected and suppressed errors, rerun with: -v
==12248== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Arch x86_64:
valgrind --leak-check=full --show-leak-kinds=all ./regnixtest
==5006== Memcheck, a memory error detector
==5006== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==5006== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==5006== Command: ./regnixtest
==5006==
Testing Create Valid NK...passed
[ normal command output snipped for brevity ]
==5006==
==5006== HEAP SUMMARY:
==5006== in use at exit: 72,704 bytes in 1 blocks
==5006== total heap usage: 2,927 allocs, 2,926 frees, 608,844,359 bytes allocated
==5006==
==5006== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
==5006== at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5006== by 0x4EC01EF: pool (eh_alloc.cc:117)
==5006== by 0x4EC01EF: __static_initialization_and_destruction_0 (eh_alloc.cc:244)
==5006== by 0x4EC01EF: _GLOBAL__sub_I_eh_alloc.cc (eh_alloc.cc:307)
==5006== by 0x400F0E9: call_init.part.0 (in /usr/lib/ld-2.21.so)
==5006== by 0x400F1FA: _dl_init (in /usr/lib/ld-2.21.so)
==5006== by 0x4000DB9: ??? (in /usr/lib/ld-2.21.so)
==5006==
==5006== LEAK SUMMARY:
==5006== definitely lost: 0 bytes in 0 blocks
==5006== indirectly lost: 0 bytes in 0 blocks
==5006== possibly lost: 0 bytes in 0 blocks
==5006== still reachable: 72,704 bytes in 1 blocks
==5006== suppressed: 0 bytes in 0 blocks
==5006==
==5006== For counts of detected and suppressed errors, rerun with: -v
==5006== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Is this a problem with one of the libraries on my Arch box? Below is the output of ldd on each in case that sheds any light:
Mint DE x86_64:
ldd ./regnixtest
linux-vdso.so.1 (0x00007ffc76ffc000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f080dcaa000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f080d9a9000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f080d792000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f080d3e9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f080dfd2000)
Arch x86_64:
ldd ./regnixtest
linux-vdso.so.1 (0x00007ffd81bd5000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fcf9d788000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fcf9d484000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fcf9d26e000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fcf9cecc000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcf9db0a000)
This project will eventually be open source, but I wasn't quite ready to put the code out there yet. If it will help, I can go ahead and put it on GitHub anyway.