The `__cxa_atexit` interceptor is disabled for `SANITIZER_AIX` because Clang on AIX neither uses `__cxa_atexit` nor links against a library with such. This interceptor calls `StopInitOrderChecking()`, which is needed to prevent false positives for the `initialization-order-fiasco` error observed in the asan test `init-order-atexit.cpp` that uses the `strict_init_order` flag. For now, we'll disable the `strict_init_order` flag, but we'll look to support it in the future by implementing an `exit` interceptor or some other alternative. With the flag disabled, we won't update `init-order-atexit.cpp` to ensure it continues to pass and the false positive doesn't show up.
30 lines
837 B
C++
30 lines
837 B
C++
// RUN: %clangxx_asan %min_macos_deployment_target=10.11 -O0 %s %p/Helpers/initialization-bug-extra.cpp -o %t
|
|
// RUN: %env_asan_opts=check_initialization_order=true:strict_init_order=true not %run %t 2>&1 | FileCheck %s
|
|
|
|
// Do not test with optimization -- the error may be optimized away.
|
|
|
|
// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=186
|
|
// XFAIL: target={{.*windows-msvc.*}}
|
|
|
|
// Fails on some Darwin bots, probably iOS.
|
|
// XFAIL: ios
|
|
|
|
// Strict init order checking is not supported on AIX
|
|
// UNSUPPORTED: target={{.*aix.*}}
|
|
|
|
#include <stdio.h>
|
|
|
|
extern int y;
|
|
|
|
void __attribute__((constructor)) ctor() {
|
|
printf("%d\n", y);
|
|
// CHECK: AddressSanitizer: initialization-order-fiasco
|
|
}
|
|
|
|
int main() {
|
|
// ASan should have caused an exit before main runs.
|
|
printf("PASS\n");
|
|
// CHECK-NOT: PASS
|
|
return 0;
|
|
}
|