From: Sergey Matveev Date: Fri, 5 Dec 2014 17:21:43 +0000 (+0000) Subject: [LSan] Rewrite the test from r223419 to not use C++11. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a03a9919f0c21548b4b4d75dc47e484eeb81a10;p=platform%2Fupstream%2Fllvm.git [LSan] Rewrite the test from r223419 to not use C++11. This was causing build failures on llvm-clang-lld-x86_64-centos-6.5 for some reason. Anyway, the new way is better because we no longer rely on std::thread implementation details. llvm-svn: 223480 --- diff --git a/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cc b/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cc index a2357e0..891cd69 100644 --- a/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cc +++ b/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cc @@ -1,15 +1,32 @@ // Regression test for http://llvm.org/bugs/show_bug.cgi?id=21621 // This test relies on timing between threads, so any failures will be flaky. // RUN: LSAN_BASE="use_stacks=0:use_registers=0" -// RUN: %clangxx_lsan %s -std=c++11 -o %t +// RUN: %clangxx_lsan %s -o %t // RUN: %run %t -#include -#include +#include +#include +#include +#include -void func() { - std::this_thread::sleep_for(std::chrono::milliseconds(500)); +void *func(void *arg) { + sleep(1); + free(arg); + return 0; +} + +void create_detached_thread() { + pthread_t thread_id; + pthread_attr_t attr; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + void *arg = malloc(1337); + assert(arg); + int res = pthread_create(&thread_id, &attr, func, arg); + assert(res == 0); } int main() { - std::thread(func).detach(); + create_detached_thread(); }