#include <assert.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sanitizer/hwasan_interface.h>
pthread_barrier_t bar;
void *threadfn(void *) {
pthread_barrier_wait(&bar);
return nullptr;
}
void start_stop_threads() {
constexpr int N = 2;
pthread_t threads[N];
pthread_barrier_init(&bar, nullptr, N + 1);
for (auto &t : threads)
pthread_create(&t, nullptr, threadfn, nullptr);
pthread_barrier_wait(&bar);
for (auto &t : threads)
pthread_join(t, nullptr);
pthread_barrier_destroy(&bar);
}
int main() {
fprintf(stderr, "=== test start ===\n");
start_stop_threads();
start_stop_threads();
start_stop_threads();
return 0;
}