[compiler-rt] r274264 - [compiler-rt] Fix TLS resource leaking in unittest

Etienne Bergeron via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 12:56:15 PDT 2016


Author: etienneb
Date: Thu Jun 30 14:56:14 2016
New Revision: 274264

URL: http://llvm.org/viewvc/llvm-project?rev=274264&view=rev
Log:
[compiler-rt] Fix TLS resource leaking in unittest

Summary:
The thread specific key wasn't not released.
Running the unittest in loop will fail after 1024 iteraions.

```
 ./projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-i386-Test --gtest_filter=SanitizerCommon.PthreadDestructorIterations --gtest_repeat=2000 --gtest_break_on_failure
```

```
Repeating all tests (iteration 1023) . . .

Note: Google Test filter = SanitizerCommon.PthreadDestructorIterations
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from SanitizerCommon
[ RUN      ] SanitizerCommon.PthreadDestructorIterations
/usr/local/google/home/etienneb/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cc:54: Failure
Value of: pthread_key_create(&key, &destructor)
  Actual: 11
Expected: 0
Aborted (core dumped)
```

Reviewers: rnk

Subscribers: kubabrecka, llvm-commits, chrisha

Differential Revision: http://reviews.llvm.org/D21902

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

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cc?rev=274264&r1=274263&r2=274264&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_posix_test.cc Thu Jun 30 14:56:14 2016
@@ -56,6 +56,7 @@ TEST(SanitizerCommon, PthreadDestructorI
   EXPECT_TRUE(destructor_executed);
   SpawnThread(GetPthreadDestructorIterations() + 1);
   EXPECT_FALSE(destructor_executed);
+  ASSERT_EQ(0, pthread_key_delete(key));
 }
 
 TEST(SanitizerCommon, IsAccessibleMemoryRange) {




More information about the llvm-commits mailing list