I am writing a cross-platform C++ program for Windows and Unix. On the Window side, the code will compile and execute no problem. On the Unix side, it will compile however when I try to run it, I get a segmentation fault. My initial hunch is that there is a problem with pointers.
What are good methodologies to find and fix segmentation fault errors?
Compile your application with -g
, then you'll have debug symbols in the binary file.
Use gdb
to open the gdb console.
Use file
and pass it your application's binary file in the console.
Use run
and pass in any arguments your application needs to start.
Do something to cause a Segmentation Fault.
Type bt
in the gdb
console to get a stack trace of the Segmentation Fault.