diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/raise1.c | 17 | ||||
-rw-r--r-- | example/raise2.c | 25 | ||||
-rw-r--r-- | example/recurse1.c | 17 | ||||
-rw-r--r-- | example/recurse2.c | 26 |
4 files changed, 85 insertions, 0 deletions
diff --git a/example/raise1.c b/example/raise1.c new file mode 100644 index 0000000..a0be4f5 --- /dev/null +++ b/example/raise1.c @@ -0,0 +1,17 @@ +#include <signal.h> + +// Raise from main thread. + +void foo() { + raise(SIGSEGV); +} +void bar() { + foo(); +} +void qux() { + bar(); +} + +int main() { + qux(); +} diff --git a/example/raise2.c b/example/raise2.c new file mode 100644 index 0000000..056a341 --- /dev/null +++ b/example/raise2.c @@ -0,0 +1,25 @@ +#include <pthread.h> +#include <signal.h> + +// Raise from different thread. + +void foo() { + raise(SIGSEGV); +} +void bar() { + foo(); +} +void qux() { + bar(); +} + +void* thread(void*) { + qux(); + return 0; +} + +int main() { + pthread_t th; + pthread_create(&th, NULL, thread, NULL); + pthread_join(th, NULL); +} diff --git a/example/recurse1.c b/example/recurse1.c new file mode 100644 index 0000000..e5a86bc --- /dev/null +++ b/example/recurse1.c @@ -0,0 +1,17 @@ +// Stack overflow on main thread. + +void qux(); + +void foo() { + qux(); +} +void bar() { + foo(); +} +void qux() { + bar(); +} + +int main() { + foo(); +} diff --git a/example/recurse2.c b/example/recurse2.c new file mode 100644 index 0000000..1fe1c4d --- /dev/null +++ b/example/recurse2.c @@ -0,0 +1,26 @@ +#include <pthread.h> + +// Stack overflow on different thread. + +void qux(); + +void foo() { + qux(); +} +void bar() { + foo(); +} +void qux() { + bar(); +} + +void* thread(void*) { + foo(); + return 0; +} + +int main() { + pthread_t th; + pthread_create(&th, NULL, thread, NULL); + pthread_join(th, NULL); +} |