Files
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

67 lines
1.9 KiB
C++

// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 66 2>&1 | FileCheck %s -check-prefix=CHECK-DIE
// RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=die_after_fork=0 %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-NODIE
#include "test.h"
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
static void *sleeper(void *p) {
barrier_wait(&barrier);
return 0;
}
static void *nop(void *p) {
return 0;
}
int main(int argc, const char **argv) {
barrier_init(&barrier, 3);
const int kSleeperThreads = 2;
barrier_init(&barrier, kSleeperThreads + 1);
pthread_t th0[kSleeperThreads];
for (int i = 0; i < kSleeperThreads; i++)
pthread_create(&th0[i], 0, sleeper, 0);
const int kNopThreads = 5;
pthread_t th1[kNopThreads];
for (int i = 0; i < kNopThreads; i++)
pthread_create(&th1[i], 0, nop, 0);
for (int i = 0; i < kNopThreads; i++)
pthread_join(th1[i], 0);
int pid = fork();
if (pid < 0) {
fprintf(stderr, "failed to fork (%d)\n", errno);
exit(1);
}
if (pid == 0) {
// child
const int kChildThreads = 4;
pthread_t th2[kChildThreads];
for (int i = 0; i < kChildThreads; i++)
pthread_create(&th2[i], 0, nop, 0);
for (int i = 0; i < kChildThreads; i++)
pthread_join(th2[i], 0);
exit(0);
return 0;
}
// parent
int expect = argc > 1 ? atoi(argv[1]) : 0;
int status = 0;
while (waitpid(pid, &status, 0) != pid) {
}
if (!WIFEXITED(status) || WEXITSTATUS(status) != expect) {
fprintf(stderr, "subprocess exited with %d, expected %d\n", status, expect);
exit(1);
}
barrier_wait(&barrier);
for (int i = 0; i < kSleeperThreads; i++)
pthread_join(th0[i], 0);
fprintf(stderr, "OK\n");
return 0;
}
// CHECK-DIE: ThreadSanitizer: starting new threads after multi-threaded fork is not supported
// CHECK-NODIE-NOT: ThreadSanitizer:
// CHECK-NODIE: OK
// CHECK-NODIE-NOT: ThreadSanitizer: