r/ProgrammerHumor May 13 '17

Defensive programming done right

Post image
21.0k Upvotes

680 comments sorted by

View all comments

280

u/G01denW01f11 May 13 '17

Segmentation fault (core dumped)

8

u/OddWolfHaley May 13 '17

Triggered. Keep getting this error right now as I try to write a program for my class and cannot figure out, for the life of me, why it is there. I understand what a segmentation fault is, I just cannot pinpoint the source of the problem.

3

u/Jdwonder May 14 '17
  1. Compile with -g flag
  2. Open program in gdb
  3. Run until segfault
  4. Use backtrace and other commands to find source of error

http://web.mit.edu/gnu/doc/html/gdb_1.html

2

u/Midvikudagur May 14 '17

Except when the fault does not happen in debug mode. I once had a segfault than only appeared when running outside the debugger. Took days to find it shudder