aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-09-28 11:01:15 +0200
committerAndreas Schneider <asn@samba.org>2018-10-23 15:38:31 +0200
commita5df8fc8f5f22ba561a39b3eb752766cb62d7f71 (patch)
tree6bafb04c04d4886ce4c494b4ffad8cc69d4673df
parentda4b908371ddc05a8402794b6929979449e4132a (diff)
downloadsocket_wrapper-a5df8fc8f5f22ba561a39b3eb752766cb62d7f71.tar.gz
socket_wrapper-a5df8fc8f5f22ba561a39b3eb752766cb62d7f71.tar.xz
socket_wrapper-a5df8fc8f5f22ba561a39b3eb752766cb62d7f71.zip
cmake: Suppress helgrind race condition warning we created on purpose
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--src/socket_wrapper.c6
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/helgrind.supp11
3 files changed, 18 insertions, 1 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 36482c6..7a27b40 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -659,6 +659,12 @@ static void swrap_mutex_unlock(pthread_mutex_t *mutex)
}
}
+/*
+ * These macros have a thread race condition on purpose!
+ *
+ * This is an optimization to avoid locking each time we check if the symbol is
+ * bound.
+ */
#define swrap_bind_symbol_libc(sym_name) \
if (swrap.libc.symbols._libc_##sym_name.obj == NULL) { \
swrap_mutex_lock(&libc_symbol_binding_mutex); \
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 068af00..6884473 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -73,7 +73,7 @@ endforeach()
if (HELGRIND_TESTING)
find_program(VALGRIND_EXECUTABLE valgrind)
if (VALGRIND_EXECUTABLE)
- set(VALGRIND_HELGRIND_OPTIONS -v --trace-children=yes --tool=helgrind --error-exitcode=1 --read-var-info=yes)
+ set(VALGRIND_HELGRIND_OPTIONS -v --trace-children=yes --tool=helgrind --error-exitcode=1 --read-var-info=yes --suppressions=${CMAKE_CURRENT_SOURCE_DIR}/helgrind.supp)
foreach(_TEST ${SWRAP_THREADED_TESTS})
set(_HELGRIND_TEST "helgrind_${_TEST}")
diff --git a/tests/helgrind.supp b/tests/helgrind.supp
new file mode 100644
index 0000000..733f714
--- /dev/null
+++ b/tests/helgrind.supp
@@ -0,0 +1,11 @@
+# The swrap_bind_symbol_lib* macros have a thread race condition on purpose!
+#
+# As an optimization we do not lock the access. However if the obj is not
+# bound, we lock it with a mutex and reread it again. And binding the symbol is
+# protected.
+{
+ SWRAP_SYMBOL_ACCESS
+ Helgrind:Race
+ fun:libc_*
+ fun:swrap_*
+}