From ad9d3a1bc25eb970681f3799d7070c97994475dc Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 2 Feb 2011 14:29:58 -0500 Subject: [PATCH] Adding example crash application. --- segfault.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 segfault.c diff --git a/segfault.c b/segfault.c new file mode 100644 index 0000000..f614290 --- /dev/null +++ b/segfault.c @@ -0,0 +1,25 @@ +/* + * segfault.c - a program that is intended to create a segmentation + * fault (SIGSEGV). + * + * No license - this code originates from Public Domain examples + * on the internet. Not that I'd want to claim copyright anyway + * on a program that is intended to crash in the first place. + */ + +int main(void) +{ + char *s = "hello world"; + int *ptr = 0; + + /* you can't write to the static variable */ + *s = 'H'; + + /* NULL ptr dereference */ + *ptr = 1; + + /* recurse without base (stack overflow) */ + main(); + + return 0; +} -- 2.7.4