Electric Fence stops your program on the exact instruction that overruns a malloc memory buffer. GDB will then display the source-code line that causes the bug. It works by using the virtual-memory hardware to create a red-zone at the border of each buffer - touch that, and your program stops.