]> Savannah Git Hosting - gnulib.git/commitdiff
get-rusage-as, pthread_sigmask tests: Fix -fsanitize=thread findings.
authorBruno Haible <bruno@clisp.org>
Sun, 10 Mar 2019 00:28:42 +0000 (01:28 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 10 Mar 2019 09:09:44 +0000 (10:09 +0100)
* lib/get-rusage-as.c (get_rusage_as): When compiled by
"gcc -fsanitize=thread", don't try get_rusage_as_via_setrlimit.
* tests/test-pthread_sigmask2.c (main): Clean up the killer_thread
before exiting.

ChangeLog
lib/get-rusage-as.c
tests/test-pthread_sigmask2.c

index 27c50744c369cd28af677059683b2e9fd740b851..5acbdfba09c0ca72389701158d7054bf2e545254 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-03-09  Bruno Haible  <bruno@clisp.org>
+
+       get-rusage-as, pthread_sigmask tests: Fix -fsanitize=thread findings.
+       * lib/get-rusage-as.c (get_rusage_as): When compiled by
+       "gcc -fsanitize=thread", don't try get_rusage_as_via_setrlimit.
+       * tests/test-pthread_sigmask2.c (main): Clean up the killer_thread
+       before exiting.
+
 2019-03-09  Jim Meyering  <meyering@fb.com>
 
        test-userspec.c: don't print NULL
index 73364c719815267454d723a707184eff1a9ac1c4..0762247d031342eae31ad9200369013c85c64272 100644 (file)
@@ -373,7 +373,7 @@ get_rusage_as_via_iterator (void)
 uintptr_t
 get_rusage_as (void)
 {
-#if (defined __APPLE__ && defined __MACH__) || defined _AIX || defined __CYGWIN__ || defined __MVS__ /* Mac OS X, AIX, Cygwin, z/OS */
+#if (defined __APPLE__ && defined __MACH__) || defined _AIX || defined __CYGWIN__ || defined __MVS__ || defined __SANITIZE_THREAD__ /* Mac OS X, AIX, Cygwin, z/OS, gcc -fsanitize=thread */
   /* get_rusage_as_via_setrlimit() does not work.
      Prefer get_rusage_as_via_iterator().  */
   return get_rusage_as_via_iterator ();
index aa7ecf46c81246b4840d4ee79539d35c60b8ced7..e02c31235bbe868a59f5b9de068fdc4cc44470f1 100644 (file)
@@ -84,6 +84,10 @@ main (int argc, char *argv[])
         before the call to pthread_sigmask() returns."  */
   ASSERT (sigint_occurred == 1);
 
+  /* Clean up the thread.  This avoid a "ThreadSanitizer: thread leak" warning
+     from "gcc -fsanitize=thread".  */
+  gl_thread_join (killer_thread, NULL);
+
   return 0;
 }