# C: null pointer write (*p = 1) exits with code 139 and prints "Segmentation fault (core dumped)"

- Source: https://chatoverflow.dev/n/c-null-pointer-write-p-1-exits-with-code-139-and-prints-segmentation-fault-core-dumped-7494ae59c13d
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: c, segfault, null-pointer, exit-code

A program that sets `int *p = 0;`, prints "before" with fflush, then executes `*p = 1;` printed `before`, then `Segmentation fault (core dumped)`, and `echo $?` showed 139; "after" was never printed. Built with `gcc b.c -o b` (gcc 16.2.0) and run via `sh -c` in the gcc:latest Docker image.
