It works. End.
Well, it's a short ode. But I can't think of anything better to say about a tool.
For the uninformed: Valgrind is a powerful debugging tool. It runs your program inside a virtual machine where it has full control over what the program does. By default, it checks for all kinds of memory handling errors: read/writes to unallocated memory, double deallocation, memory leaks, and most amazingly, reads from allocated, but uninitialized memory.
Linux: Ode to valgrind
- wrtlprnft
- Reverse Outside Corner Grinder
- Posts: 1679
- Joined: Wed Jan 04, 2006 4:42 am
- Location: 0x08048000
- Contact:
sorry for digging out this old thread, but I tried it (mostly to check my own code), and out of frustration that it didn't find anything in my code I'll post this (CVS HEAD):Not sure exactly, but for reference, this is tMemManager.cpp:619:That might have something to do with the special nature of the memory manager, but the only time something writes to the leaks array is inside this if block...
Code: Select all
==21111== Conditional jump or move depends on uninitialised value(s)
==21111== at 0x81E4B73: tMemManager::tMemManager(int) (tMemManager.cpp:619)
==21111== by 0x81E654A: __static_initialization_and_destruction_0(int, int) (tMemManager.cpp:964)
==21111== by 0x81E72F9: _GLOBAL__I__Z4leakv (sstream.tcc:80)
==21111== by 0x81EE7E4: (within /home/mathias/armagetronad/src/armagetronad_main)
==21111== by 0x804EDA8: (within /home/mathias/armagetronad/src/armagetronad_main)
==21111== by 0x81EE6DA: __libc_csu_init (in /home/mathias/armagetronad/src/armagetronad_main)
==21111== by 0x4493081: (below main) (in /lib/libc-2.3.5.so)
Code: Select all
if (cs>=0 && cs < MAXCHECKSUM && (ln < leaks[cs] || leaks[cs] == 0))
There's no place like ::1
Valgrind is constantly cooler. Release 3.3 includes exp-omega, a memory checker that can report leaks as they happen, i.e. when the last pointer to a memory block gets assigned to point somewhere else. At the end, you'll get told where the block was allocated, and what bit of code lost it. Immensely useful.