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
9volatile int state;
10
11void *Increment(void *arg) {
12 ++state;
13 return NULL;
14}
15
16int main() {
17 __hwasan_enable_allocator_tagging();
18 pthread_t t1;
19 pthread_create(newthread: &t1, NULL, start_routine: Increment, NULL);
20 pthread_join(th: t1, NULL);
21}
22

source code of compiler-rt/test/hwasan/TestCases/pthread_create.c