[compiler-rt] r367705 - [sanitizer_common][tests] Fix SanitizerCommon-Unit :: ./Sanitizer-*-Test/SanitizerCommon.PthreadDestructorIterations on Solaris

Rainer Orth via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 2 11:55:22 PDT 2019


Author: ro
Date: Fri Aug  2 11:55:22 2019
New Revision: 367705

URL: http://llvm.org/viewvc/llvm-project?rev=367705&view=rev
Log:
[sanitizer_common][tests] Fix SanitizerCommon-Unit :: ./Sanitizer-*-Test/SanitizerCommon.PthreadDestructorIterations on Solaris

SanitizerCommon.PthreadDestructorIterations currently FAILs on Solaris:

  [ RUN      ] SanitizerCommon.PthreadDestructorIterations
  /vol/llvm/src/compiler-rt/local/lib/sanitizer_common/tests/sanitizer_posix_test.cc:58: Failure
  Value of: destructor_executed
    Actual: true
  Expected: false
  [  FAILED  ] SanitizerCommon.PthreadDestructorIterations (1 ms)

It turns out that destructor is called 4 times after the first call to SpawnThread, but
5 times after the second.  While PTHREAD_DESTRUCTOR_ITERATIONS is 4 in
<limits.h>, the Solaris pthread_key_create(3C) man page documents

  If, after all the destructors have been called for all keys  with  non-
  null  values,  there  are  still  some  keys  with non-null values, the
  process will be repeated. POSIX requires that this process be  executed
  at   least   PTHREAD_DESTRUCTOR_ITERATIONS  times.  Solaris  calls  the
  destructors repeatedly until all values with associated destructors are
  NULL. Destructors that set new values can cause an infinite loop.

The patch adjusts the test case to allow for this.

Tested on x86_64-pc-solaris2.11.

Differential Revision: https://reviews.llvm.org/D65055

Modified:
    compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cpp

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cpp?rev=367705&r1=367704&r2=367705&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cpp (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cpp Fri Aug  2 11:55:22 2019
@@ -54,7 +54,12 @@ TEST(SanitizerCommon, PthreadDestructorI
   SpawnThread(GetPthreadDestructorIterations());
   EXPECT_TRUE(destructor_executed);
   SpawnThread(GetPthreadDestructorIterations() + 1);
+#if SANITIZER_SOLARIS
+  // Solaris continues calling destructors beyond PTHREAD_DESTRUCTOR_ITERATIONS.
+  EXPECT_TRUE(destructor_executed);
+#else
   EXPECT_FALSE(destructor_executed);
+#endif
   ASSERT_EQ(0, pthread_key_delete(key));
 }
 




More information about the llvm-commits mailing list