Run the code with gdb ./yourCode Use 'run' command to start the program. When it crashes use 'bt'(back trace) command to find where it happened.