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.
14 #include <sanitizer/common_interface_defs.h>
17 class ThreadContextLsanBase
*GetCurrentThread();
20 void *try_to_crash(void *args
) {
21 for (int i
= 0; i
< 100000; ++i
)
22 __lsan::GetCurrentThread();
26 int main(int argc
, char **argv
) {
27 std::vector
<pthread_t
> threads
;
28 for (int i
= 0; i
< atoi(argv
[1]); ++i
) {
30 for (auto &thread
: threads
)
31 pthread_create(&thread
, 0, try_to_crash
, NULL
);
33 for (auto &thread
: threads
)
34 pthread_join(thread
, nullptr);