| 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, "INIT\n"); |
| 16 |
struct sigaction old; |
| 17 |
assert(!sigaction(SIGSEGV, nullptr, &old)); |
| 18 |
}; |
| 19 |
|
| 20 |
int main() { |
| 21 |
fprintf(stderr, "DONE\n"); |
| 22 |
return 0; |
| 23 |
} |
| 24 |
|
| 25 |
// CHECK: INIT |
| 26 |
// CHECK: DONE |