CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
// RUN: %clang_tsan -fno-sanitize=thread -shared -fPIC -O1 -DBUILD_SO=1 %s -o \
|
|
// RUN: %t.so && \
|
|
// RUN: %clang_tsan -O1 %s %t.so -o %t && %run %t 2>&1 | FileCheck %s
|
|
// RUN: llvm-objdump -t %t | FileCheck %s --check-prefix=CHECK-DUMP
|
|
// CHECK-DUMP: {{[.]preinit_array.*preinit}}
|
|
|
|
// SANITIZER_CAN_USE_PREINIT_ARRAY is undefined on android.
|
|
// UNSUPPORTED: android
|
|
|
|
// Test checks if __tsan_init is called from .preinit_array.
|
|
// Without initialization from .preinit_array, __tsan_init will be called from
|
|
// constructors of the binary which are called after constructors of shared
|
|
// library.
|
|
|
|
#include <sanitizer/tsan_interface.h>
|
|
#include <stdio.h>
|
|
|
|
#if BUILD_SO
|
|
|
|
// "volatile" is needed to avoid compiler optimize-out constructors.
|
|
volatile int counter = 0;
|
|
volatile int lib_constructor_call = 0;
|
|
volatile int tsan_init_call = 0;
|
|
|
|
__attribute__ ((constructor))
|
|
void LibConstructor() {
|
|
lib_constructor_call = ++counter;
|
|
};
|
|
|
|
#else // BUILD_SO
|
|
|
|
extern int counter;
|
|
extern int lib_constructor_call;
|
|
extern int tsan_init_call;
|
|
|
|
volatile int bin_constructor_call = 0;
|
|
|
|
__attribute__ ((constructor))
|
|
void BinConstructor() {
|
|
bin_constructor_call = ++counter;
|
|
};
|
|
|
|
namespace __tsan {
|
|
|
|
void OnInitialize() {
|
|
tsan_init_call = ++counter;
|
|
}
|
|
|
|
}
|
|
|
|
int main() {
|
|
// CHECK: TSAN_INIT 1
|
|
// CHECK: LIB_CONSTRUCTOR 2
|
|
// CHECK: BIN_CONSTRUCTOR 3
|
|
printf("TSAN_INIT %d\n", tsan_init_call);
|
|
printf("LIB_CONSTRUCTOR %d\n", lib_constructor_call);
|
|
printf("BIN_CONSTRUCTOR %d\n", bin_constructor_call);
|
|
return 0;
|
|
}
|
|
|
|
#endif // BUILD_SO
|