[PATCH] D65055: [sanitizer_common][tests] Fix SanitizerCommon-Unit :: ./Sanitizer-*-Test/SanitizerCommon.PthreadDestructorIterations on Solaris

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 21 08:30:07 PDT 2019


ro created this revision.
ro added reviewers: kcc, samsonov.
ro added a project: Sanitizers.
Herald added subscribers: Sanitizers, jfb, fedor.sergeev, kubamracek.
Herald added a project: LLVM.

`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`.  Ok for trunk?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D65055

Files:
  lib/sanitizer_common/tests/sanitizer_posix_test.cc


Index: lib/sanitizer_common/tests/sanitizer_posix_test.cc
===================================================================
--- lib/sanitizer_common/tests/sanitizer_posix_test.cc
+++ lib/sanitizer_common/tests/sanitizer_posix_test.cc
@@ -54,7 +54,12 @@
   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));
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65055.210984.patch
Type: text/x-patch
Size: 638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190721/5540cc28/attachment.bin>


More information about the llvm-commits mailing list