changeset 40220:2796695e9216

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.
author Bruno Haible <bruno@clisp.org>
date Sun, 10 Mar 2019 01:28:42 +0100
parents 53cae2062bf4
children 8c1a17df67e0
files ChangeLog lib/get-rusage-as.c tests/test-pthread_sigmask2.c
diffstat 3 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 09 21:38:03 2019 -0800
+++ b/ChangeLog	Sun Mar 10 01:28:42 2019 +0100
@@ -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
--- a/lib/get-rusage-as.c	Sat Mar 09 21:38:03 2019 -0800
+++ b/lib/get-rusage-as.c	Sun Mar 10 01:28:42 2019 +0100
@@ -373,7 +373,7 @@
 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 ();
--- a/tests/test-pthread_sigmask2.c	Sat Mar 09 21:38:03 2019 -0800
+++ b/tests/test-pthread_sigmask2.c	Sun Mar 10 01:28:42 2019 +0100
@@ -84,6 +84,10 @@
         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;
 }