Investigating Segmentation Faults and Debugging Tools
<p>After compiling a C++ program with make and gcc I experienced a segmentation fault while running. The program just exited without any error message.</p>

<p>Even though I didn't compile the program in debug mode, by running it with gdb I actually got an error message to see where the segfault happened.</p>

<p>What I would like to know is:</p>

<ul>
<li>Why did gdb display the line causing the error, but the regular bash did not?</li>
<li>How can the gdb display the line when the program was not compiled in debug mode?</li>
<li>In the past I always re-compiled in debug mode (to attatch the symbolic table to the binaries) and investigted the backtrace of the core dump with ddd. Is this the proper way to fix segmentation faults, or what is the common way to do it?</li>
</ul>