1#include <pthread.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5char *pointer;
6
7void *f1(void *p) {
8 pointer[0] = 'x'; // thread1 line
9 return NULL;
10}
11
12void *f2(void *p) {
13 pointer[0] = 'y'; // thread2 line
14 return NULL;
15}
16
17int main (int argc, char const *argv[])
18{
19 for (int i = 0; i < 100; i++) {
20 pointer = (char *)malloc(size: 10); // malloc line
21
22 pthread_t t1, t2;
23 pthread_create(newthread: &t1, NULL, start_routine: f1, NULL);
24 pthread_create(newthread: &t2, NULL, start_routine: f2, NULL);
25
26 pthread_join(th: t1, NULL);
27 pthread_join(th: t2, NULL);
28
29 free(ptr: pointer);
30 }
31 return 0;
32}
33

source code of lldb/test/API/functionalities/tsan/basic/main.c