[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix -fsanitize=thread findings
From: |
Bruno Haible |
Subject: |
fix -fsanitize=thread findings |
Date: |
Sun, 10 Mar 2019 10:11:07 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; ) |
Applying CC="gcc -fsanitize=thread" to a gnulib testdir, I see
these findings:
test-get-rusage-as:
ERROR: ThreadSanitizer failed to allocate 0x12000 (73728) bytes of
SignalContext (errno: 12)
ERROR: Failed to mmap
test-pthread-sigmask2:
WARNING: ThreadSanitizer: thread leak (pid=7460)
test-lock:
FATAL: ThreadSanitizer CHECK failed:
../../../../src/libsanitizer/sanitizer_common/sanitizer_deadlock_detector.h:67
"((n_all_locks_)) <
(((sizeof(all_locks_with_contexts_)/sizeof((all_locks_with_contexts_)[0]))))"
(0x40, 0x40)
#0 <null> <null> (libtsan.so.0+0x000000075193)
#1 <null> <null> (libtsan.so.0+0x00000007519b)
#2 __sanitizer::CheckFailed(char const*, int, char const*, unsigned long
long, unsigned long long) <null> (libtsan.so.0+0x000000079ce3)
#3 <null> <null> (libtsan.so.0+0x00000007dacd)
#4 <null> <null> (libtsan.so.0+0x000000071b95)
#5 pthread_rwlock_wrlock <null> (libtsan.so.0+0x000000028e95)
#6 test_once ../../gltests/test-lock.c:646 (test-lock+0x000000401dea)
#7 main ../../gltests/test-lock.c:738 (test-lock+0x000000401dea)
test-getgroups:
eats up all available memory before being killed by the kernel.
This patch fixes the first two issues. The last two are beyond my control.
2019-03-09 Bruno Haible <address@hidden>
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.
diff --git a/lib/get-rusage-as.c b/lib/get-rusage-as.c
index 73364c7..0762247 100644
--- a/lib/get-rusage-as.c
+++ b/lib/get-rusage-as.c
@@ -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 ();
diff --git a/tests/test-pthread_sigmask2.c b/tests/test-pthread_sigmask2.c
index aa7ecf4..e02c312 100644
--- a/tests/test-pthread_sigmask2.c
+++ b/tests/test-pthread_sigmask2.c
@@ -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;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- fix -fsanitize=thread findings,
Bruno Haible <=