brintos

brintos / llvm-project-archived public Read only

0
0
Text · 726 B · 241caa2 Raw
33 lines · cpp
1// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && %run %t2 3// Regression test for a deadlock in pthread_getattr_np4 5#include <assert.h>6#include <pthread.h>7#if defined(__FreeBSD__)8#include <pthread_np.h>9#endif10 11void *ThreadFn(void *) {12  pthread_attr_t attr;13#if defined(__FreeBSD__)14  // On FreeBSD it needs to allocate attr underlying memory15  int res = pthread_attr_init(&attr);16  assert(!res);17  res = pthread_attr_get_np(pthread_self(), &attr);18#else19  int res = pthread_getattr_np(pthread_self(), &attr);20#endif21  assert(!res);22  return 0;23}24 25int main(void) {26  pthread_t t;27  int res = pthread_create(&t, 0, ThreadFn, 0);28  assert(!res);29  res = pthread_join(t, 0);30  assert(!res);31  return 0;32}33