mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
So we don't have to pull in gcc and other stuff into it. Also, make the test itself a bit more robust and debug-able.
30 lines
492 B
C
30 lines
492 B
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
|
|
/* This is a test program that intentionally segfaults so we can generate a
|
|
* predictable-ish stack trace in tests. */
|
|
|
|
#include <stdlib.h>
|
|
|
|
__attribute__((noinline))
|
|
static void baz(int *x) {
|
|
*x = rand();
|
|
}
|
|
|
|
__attribute__((noinline))
|
|
static void bar(void) {
|
|
int * volatile x = NULL;
|
|
|
|
baz(x);
|
|
}
|
|
|
|
__attribute__((noinline))
|
|
static void foo(void) {
|
|
bar();
|
|
}
|
|
|
|
int main(void) {
|
|
foo();
|
|
|
|
return 0;
|
|
}
|