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
81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
|
|
|
|
// Test case for longjumping out of signal handler:
|
|
// https://github.com/google/sanitizers/issues/482
|
|
|
|
// This test fails on powerpc64 BE (VMA=44), a segmentation fault
|
|
// error happens at the second assignment
|
|
// "((volatile int *volatile)mem)[1] = 1".
|
|
// XFAIL: target=powerpc64-unknown-linux-gnu{{.*}}
|
|
|
|
#include <setjmp.h>
|
|
#include <signal.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <sys/mman.h>
|
|
|
|
#ifdef __APPLE__
|
|
#define SIGNAL_TO_HANDLE SIGBUS
|
|
#else
|
|
#define SIGNAL_TO_HANDLE SIGSEGV
|
|
#endif
|
|
|
|
sigjmp_buf fault_jmp;
|
|
volatile int fault_expected;
|
|
|
|
void sigfault_handler(int sig) {
|
|
if (!fault_expected)
|
|
abort();
|
|
|
|
/* just return from sighandler to proper place */
|
|
fault_expected = 0;
|
|
siglongjmp(fault_jmp, 1);
|
|
}
|
|
|
|
#define MUST_FAULT(code) do { \
|
|
fault_expected = 1; \
|
|
if (!sigsetjmp(fault_jmp, 1)) { \
|
|
code; /* should pagefault -> sihandler does longjmp */ \
|
|
fprintf(stderr, "%s not faulted\n", #code); \
|
|
abort(); \
|
|
} else { \
|
|
fprintf(stderr, "%s faulted ok\n", #code); \
|
|
} \
|
|
} while (0)
|
|
|
|
int main() {
|
|
struct sigaction act;
|
|
act.sa_handler = sigfault_handler;
|
|
act.sa_flags = 0;
|
|
if (sigemptyset(&act.sa_mask)) {
|
|
perror("sigemptyset");
|
|
exit(1);
|
|
}
|
|
|
|
if (sigaction(SIGNAL_TO_HANDLE, &act, NULL)) {
|
|
perror("sigaction");
|
|
exit(1);
|
|
}
|
|
|
|
void *mem = mmap(0, 4096, PROT_NONE, MAP_PRIVATE | MAP_ANON,
|
|
-1, 0);
|
|
|
|
MUST_FAULT(((volatile int *volatile)mem)[0] = 0);
|
|
MUST_FAULT(((volatile int *volatile)mem)[1] = 1);
|
|
MUST_FAULT(((volatile int *volatile)mem)[3] = 1);
|
|
|
|
// Ensure that tsan does not think that we are
|
|
// in a signal handler.
|
|
void *volatile p = malloc(10);
|
|
((volatile int*)p)[1] = 1;
|
|
free((void*)p);
|
|
|
|
munmap(p, 4096);
|
|
|
|
fprintf(stderr, "DONE\n");
|
|
return 0;
|
|
}
|
|
|
|
// CHECK-NOT: WARNING: ThreadSanitizer
|
|
// CHECK: DONE
|