Adding example crash application.
authorAuke Kok <auke-jan.h.kok@intel.com>
Wed, 2 Feb 2011 19:29:58 +0000 (14:29 -0500)
committerAuke Kok <auke-jan.h.kok@intel.com>
Wed, 2 Feb 2011 19:29:58 +0000 (14:29 -0500)
segfault.c [new file with mode: 0644]

diff --git a/segfault.c b/segfault.c
new file mode 100644 (file)
index 0000000..f614290
--- /dev/null
@@ -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;
+}