Issue
I'm trying to set up the way my server handles core dumps. In order to test it, I'd need a program that always segfaults.
Is there a simple example program that always segfaults?
Solution
main;
Is portable, and segfault in 5chars.
It's a variable declaration - int
type is implied (feature copied from B language) and 0
is default value. When executed this tries to execute a number (numbers aren't executable), and causes SIGSEGV
.
Source: https://codegolf.stackexchange.com/questions/4399/shortest-code-that-raises-a-sigsegv
Answered By - Thomas Coudray Answer Checked By - David Marino (WPSolving Volunteer)