| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
/* This is a test program that intentionally segfaults so we can generate a |
| 4 |
* predictable-ish stack trace in tests. */ |
| 5 |
|
| 6 |
#include <stdlib.h> |
| 7 |
|
| 8 |
__attribute__((noinline)) |
| 9 |
static void baz(int *x) { |
| 10 |
*x = rand(); |
| 11 |
} |
| 12 |
|
| 13 |
__attribute__((noinline)) |
| 14 |
static void bar(void) { |
| 15 |
int * volatile x = NULL; |
| 16 |
|
| 17 |
baz(x); |
| 18 |
} |
| 19 |
|
| 20 |
__attribute__((noinline)) |
| 21 |
static void foo(void) { |
| 22 |
bar(); |
| 23 |
} |
| 24 |
|
| 25 |
int main(void) { |
| 26 |
foo(); |
| 27 |
|
| 28 |
return 0; |
| 29 |
} |