Skip to content

Instantly share code, notes, and snippets.

@henryscala
Created February 23, 2016 02:24
Show Gist options
  • Save henryscala/55cff87c989feaae7c15 to your computer and use it in GitHub Desktop.
Save henryscala/55cff87c989feaae7c15 to your computer and use it in GitHub Desktop.
to force a coredump
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
/* this program tries to generate a crash. A prove of concept program. */
/* as per my test, crash may be created in other diectory, but not in my $HOME directory, I don't know why yet */
void function1() {
printf("%s\n","in function1");
raise(SIGSEGV);
//
//abort(); not work
//assert(false);
//while(true) {
// sleep(1);
//
//}
}
void function2() {
printf("in function2\n");
function1();
}
int main() {
function2();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment