xref: /llvm-project/compiler-rt/test/hwasan/TestCases/pthread_create.c (revision fdac98a7f3bbe0cb553df60df8cca2e8f407fa51)
1 // Tests that our thread initialization hooks work properly with random_tags=1.
2 // RUN: %clang_hwasan %s -o %t
3 // RUN: %env_hwasan_opts=random_tags=1 %run %t
4 
5 #include <pthread.h>
6 
7 #include <sanitizer/hwasan_interface.h>
8 
9 volatile int state;
10 
Increment(void * arg)11 void *Increment(void *arg) {
12   ++state;
13   return NULL;
14 }
15 
main()16 int main() {
17   __hwasan_enable_allocator_tagging();
18   pthread_t t1;
19   pthread_create(&t1, NULL, Increment, NULL);
20   pthread_join(t1, NULL);
21 }
22