HALF ECHO LEARN / REFERENCE COLLECTION
v262.2src/test/test-coredump-stacktrace.c
Git blob: 334a155a9c17e59b335b2080e68d6b4da633a569
Lines 1–30 of 30
/* 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;
}