Although C is undisputedly the standard programming language on Linux systems, C has a number of features that lead programmers into writing code with subtle bugs that can be very hard to debug. Memory leaks (in which
malloc() ed memory is never
free() ed) and buffer overflows (writing past the end of an array, for example) are two of the most common and difficult-to-detect program bugs; buffer underruns (writing before the beginning of an array, for example) are much less common but usually even harder to track down. This chapter presents a few debugging tools that greatly simplify the detection and isolation of such problems.
1: /* broken.c */ 2: 3: #include <stdlib.h> 4: #include <stdio.h> 5: #include ...