llvm/compiler-rt/test/hwasan/TestCases/pthread_create.c

// Tests that our thread initialization hooks work properly with random_tags=1.
// RUN: %clang_hwasan %s -o %t
// RUN: %env_hwasan_opts=random_tags=1 %run %t

#include <pthread.h>

#include <sanitizer/hwasan_interface.h>

volatile int state;

void *Increment(void *arg) {
  ++state;
  return NULL;
}

int main() {
  __hwasan_enable_allocator_tagging();
  pthread_t t1;
  pthread_create(&t1, NULL, Increment, NULL);
  pthread_join(t1, NULL);
}