[Flang][OpenMP]Add parsing support for DISPATCH construct (#121982)
[llvm-project.git] / compiler-rt / test / lsan / TestCases / thread_context_crash.cpp
blob815967ca780eafb96fda11c1caf8232199a52815
1 // Check that concurent GetCurrentThread does not crash.
2 // RUN: %clangxx_lsan -O3 -pthread %s -o %t && %run %t 100
4 // REQUIRES: lsan-standalone
6 // For unknown reason linker can't resolve GetCurrentThread on
7 // https://ci.chromium.org/p/chromium/builders/try/mac_upload_clang.
8 // UNSUPPORTED: darwin
10 #include <pthread.h>
11 #include <stdlib.h>
12 #include <vector>
14 #include <sanitizer/common_interface_defs.h>
16 namespace __lsan {
17 class ThreadContextLsanBase *GetCurrentThread();
20 void *try_to_crash(void *args) {
21 for (int i = 0; i < 100000; ++i)
22 __lsan::GetCurrentThread();
23 return nullptr;
26 int main(int argc, char **argv) {
27 std::vector<pthread_t> threads;
28 for (int i = 0; i < atoi(argv[1]); ++i) {
29 threads.resize(10);
30 for (auto &thread : threads)
31 pthread_create(&thread, 0, try_to_crash, NULL);
33 for (auto &thread : threads)
34 pthread_join(thread, nullptr);
36 return 0;