A segmentation fault is a specific kind of error caused by accessing memory that “does not belong to you.” It’s a mechanism that prevents you from corrupting the memory and introducing hard-to-debug memory bugs. Whenever you get a segmentation fault, you know you are doing something wrong with memory – such as accessing a variable that has already been freed or writing to a read-only portion of memory. The operating system kills the process after a segmentation fault occurs to protect other processes in the system.