// https://syzkaller.appspot.com/bug?id=ecfc15aee4109a4a3ba93cfb510a0383aed8602e #define _GNU_SOURCE #include #include #include #include #include #include static void *dummy_worker(void *arg) { return NULL; } static void *worker(void *arg) { for (int i = 0; i < 10000; i++) { pthread_t th; if (pthread_create(&th, NULL, dummy_worker, NULL) == 0) { pthread_join(th, NULL); } } return NULL; } int main(void) { setvbuf(stdout, NULL, _IONBF, 0); printf("[*] Starting KCSAN data-race reproducer...\n"); pthread_t th[16]; for (int i = 0; i < 16; i++) { int res = pthread_create(&th[i], NULL, worker, NULL); if (res != 0) { printf("[-] Failed to pthread_create worker %d: %s\n", i, strerror(res)); exit(1); } } printf("[+] Workers created successfully.\n"); for (int i = 0; i < 16; i++) { int res = pthread_join(th[i], NULL); if (res != 0) { printf("[-] Failed to pthread_join worker %d: %s\n", i, strerror(res)); exit(1); } } printf("[+] Workers joined successfully.\n"); return 0; }