1// RUN: %clangxx -fsanitize=undefined -shared-libsan %s -o %t && %run %t 2>&1 | FileCheck %s
2
3// Ensure ubsan runtime/interceptors are lazily initialized if called early.
4
5// The test seems to segfault on aarch64 with tsan:
6// https://lab.llvm.org/buildbot/#/builders/179/builds/6662
7// Reason unknown, needs debugging.
8// UNSUPPORTED: target=aarch64{{.*}} && ubsan-tsan
9
10#include <assert.h>
11#include <signal.h>
12#include <stdio.h>
13
14__attribute__((constructor(1))) void ctor() {
15 fprintf(stderr, format: "INIT\n");
16 struct sigaction old;
17 assert(!sigaction(SIGSEGV, nullptr, &old));
18};
19
20int main() {
21 fprintf(stderr, format: "DONE\n");
22 return 0;
23}
24
25// CHECK: INIT
26// CHECK: DONE
27

source code of compiler-rt/test/ubsan/TestCases/Misc/Linux/sigaction.cpp