[compiler-rt] r223480 - [LSan] Rewrite the test from r223419 to not use C++11.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Dec 19 04:17:43 PST 2014


This test is flaky:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/14754/steps/run%20sanitizer%20tests%20in%20gcc%20build/logs/stdio

On Fri, Dec 5, 2014 at 8:21 PM, Sergey Matveev <earthdok at google.com> wrote:
> Author: smatveev
> Date: Fri Dec  5 11:21:43 2014
> New Revision: 223480
>
> URL: http://llvm.org/viewvc/llvm-project?rev=223480&view=rev
> Log:
> [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.
>
> Modified:
>     compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc
>
> Modified: compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc?rev=223480&r1=223479&r2=223480&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc (original)
> +++ compiler-rt/trunk/test/lsan/TestCases/leak_check_before_thread_started.cc Fri Dec  5 11:21:43 2014
> @@ -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 <thread>
> -#include <chrono>
> +#include <assert.h>
> +#include <pthread.h>
> +#include <stdlib.h>
> +#include <unistd.h>
>
> -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();
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list