Process attempts to read or write to an invalid memory address.
A Segmentation Fault occurs when a program attempts to access a memory location that it does not have permission to access, or that does not exist (such as NULL).
Dereferencing NULL pointers, accessing array elements out of bounds, writing to read-only string literals, or dereferencing dangling pointers after memory is freed.
1#include <stdio.h>2 3int main() {4 int *ptr = NULL;5 *ptr = 42; // SIGSEGV: Dereferencing NULL pointer!6 return 0;7}1#include <stdio.h>2#include <stdlib.h>3 4int main() {5 int *ptr = malloc(sizeof(int));6 7 // Fix 1: Always check pointer allocation before dereferencing8 if (ptr != NULL) {9 *ptr = 42;10 printf("Value: %d\n", *ptr);11 free(ptr);12 ptr = NULL; // Prevent dangling pointer13 }14 return 0;15}Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
Pointer `ptr` is initialized to `NULL` (address 0x0). Writing `*ptr = 42` attempts to write to restricted kernel memory address 0, causing operating system hardware fault signal SIGSEGV.