You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jd...@apache.org on 2021/03/19 18:54:13 UTC
[qpid-dispatch] branch master updated: DISPATCH-1962 Make LSan
suppressions more targeted and specific (#1048)
This is an automated email from the ASF dual-hosted git repository.
jdanek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new c6ea12e DISPATCH-1962 Make LSan suppressions more targeted and specific (#1048)
c6ea12e is described below
commit c6ea12e4d0831526b1a7a27958a33de5641d9cdb
Author: Jiri Daněk <jd...@redhat.com>
AuthorDate: Fri Mar 19 19:54:04 2021 +0100
DISPATCH-1962 Make LSan suppressions more targeted and specific (#1048)
---
.github/workflows/build.yaml | 1 +
cmake/RuntimeChecks.cmake | 20 +++++++++++-
pom.xml | 1 +
tests/lsan.supp | 78 +++++++++++++++++++++++++++++++++++++++-----
tests/lsan_3rdparty.supp | 4 +++
5 files changed, 95 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 859daa0..dc5c320 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -53,6 +53,7 @@ jobs:
-DCONSOLE_INSTALL=OFF
-DUSE_BWRAP=ON
-DRUNTIME_CHECK=${{matrix.runtimeCheck}}
+ -DSANITIZE_3RD_PARTY=ON
CCACHE_BASEDIR: ${{github.workspace}}
CCACHE_DIR: ${{github.workspace}}/.ccache
diff --git a/cmake/RuntimeChecks.cmake b/cmake/RuntimeChecks.cmake
index 86f6b0f..b2020fd 100644
--- a/cmake/RuntimeChecks.cmake
+++ b/cmake/RuntimeChecks.cmake
@@ -106,9 +106,27 @@ elseif(RUNTIME_CHECK STREQUAL "asan")
message(FATAL_ERROR "libubsan not installed - address sanitizer not available")
endif(UBSAN_LIBRARY-NOTFOUND)
message(STATUS "Runtime memory checker: gcc/clang address sanitizers")
+ option(SANITIZE_3RD_PARTY "Detect leaks in 3rd party libraries used by Dispatch while running tests" OFF)
+ if (SANITIZE_3RD_PARTY)
+ add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/tests/lsan.supp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/tests/lsan.supp ${CMAKE_BINARY_DIR}/tests/lsan.supp
+ DEPENDS ${CMAKE_SOURCE_DIR}/tests/lsan.supp
+ VERBATIM)
+ else (SANITIZE_3RD_PARTY)
+ # Append wholesale library suppressions
+ # this is necessary if target system does not have debug symbols for these libraries installed
+ # and therefore the more specific suppressions do not match
+ add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/tests/lsan.supp
+ COMMAND bash -c 'cat ${CMAKE_SOURCE_DIR}/tests/lsan.supp ${CMAKE_SOURCE_DIR}/tests/lsan_3rdparty.supp > ${CMAKE_BINARY_DIR}/tests/lsan.supp'
+ DEPENDS ${CMAKE_SOURCE_DIR}/tests/lsan.supp ${CMAKE_SOURCE_DIR}/tests/lsan_3rdparty.supp)
+ endif ()
+ add_custom_target(generate_lsan.supp ALL
+ DEPENDS ${CMAKE_BINARY_DIR}/tests/lsan.supp)
set(SANITIZE_FLAGS "-g -fno-omit-frame-pointer -fsanitize=address,undefined")
set(RUNTIME_ASAN_ENV_OPTIONS "detect_leaks=true suppressions=${CMAKE_SOURCE_DIR}/tests/asan.supp")
- set(RUNTIME_LSAN_ENV_OPTIONS "suppressions=${CMAKE_SOURCE_DIR}/tests/lsan.supp")
+ set(RUNTIME_LSAN_ENV_OPTIONS "suppressions=${CMAKE_BINARY_DIR}/tests/lsan.supp")
elseif(RUNTIME_CHECK STREQUAL "tsan")
assert_has_sanitizers()
diff --git a/pom.xml b/pom.xml
index 9814e94..93ad212 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,6 +96,7 @@
<exclude>**/tsan.supp</exclude>
<exclude>**/asan.supp</exclude>
<exclude>**/lsan.supp</exclude>
+ <exclude>**/lsan_3rdparty.supp</exclude>
<exclude>**/*.json.in</exclude>
<exclude>**/*.json</exclude>
<exclude>**/*.svg</exclude>
diff --git a/tests/lsan.supp b/tests/lsan.supp
index ae96114..fcb18ca 100644
--- a/tests/lsan.supp
+++ b/tests/lsan.supp
@@ -10,6 +10,27 @@ leak:qd_policy_c_counts_alloc
leak:qd_policy_open_fetch_settings
leak:qdr_error_description
+# to be triaged; unit_tests
+leak:http-libwebsockets.c
+
+# to be triaged; pretty much all tests
+leak:^IoAdapter_init$
+
+# to be triaged; system_tests_http
+leak:^callback_healthz$
+leak:^callback_metrics$
+
+# to be triaged; system_tests_http1_adaptor
+leak:^pn_condition$
+leak:^pn_raw_connection$
+leak:^pgetaddrinfo$
+
+# to be triaged; system_tests_link_routes
+leak:^pni_init_default_logger$
+
+# Ignore test code
+leak:run_unit_tests.c
+
# DISPATCH-1844 - shutdown leak
leak:sys_mutex
@@ -23,15 +44,56 @@ leak:_ctypes_alloc_format_string
leak:__strdup
####
-#### Miscellaneous 3rd party libraries, test code, etc:
+#### Miscellaneous 3rd party libraries:
####
-leak:*libpython*
-leak:*libwebsockets*
-leak:*python2*
+### Python
-# We should be able to uncomment these once all known dispatch leaks have been fixed
-leak:*libqpid-proton*
+# these Python leaks happen even after simple Py_Initialize(); Py_Finalize();
+# https://bugs.python.org/issue1635741
+leak:^_PyObject_Realloc
+leak:^PyObject_Malloc$
+leak:^PyThread_allocate_lock$
-# Ignore test code
-leak:run_unit_tests.c
+# the PyMalloc mechanism is incompatible with Valgrind, it must be disabled or reported "leaks" must be suppressed
+# https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug_python.html#debug-version-of-python-memory-alloc-label
+leak:^PyMem_Malloc$
+leak:^PyMem_Calloc$
+leak:^_PyObject_GC_Resize$
+# Python uses these alloc functions if you define PYTHONDEVMODE=1
+leak:^_PyMem_DebugRawAlloc$
+leak:^_PyMem_DebugRawRealloc$
+# All the rest
+leak:^list_append$
+leak:^list_resize$
+leak:^_PyBytes_Resize$
+leak:^resize_compact$
+leak:^unicode_resize$
+# Python 2.7
+leak:^PyString_FromStringAndSize$
+leak:^PyString_FromString$
+leak:^PyObject_Realloc$
+leak:^_PyObject_GC_Malloc$
+leak:^_PyString_Resize$
+leak:^PyUnicodeUCS4_FromUnicode$
+leak:^PyList_Append$
+leak:^PyList_New$
+
+### Qpid Proton
+
+# Proton suppressions taken from Proton's lsan.supp
+# this appears in system_tests_open_properties:
+leak:^pni_data_grow$
+leak:^pn_buffer$
+leak:^pn_buffer_ensure$
+# this appears in system_tests_http1_adaptor:
+leak:^pn_string_grow$
+leak:^pn_object_new$
+leak:^pn_list$
+leak:^pni_record_create$
+
+### libwebsockets
+
+leak:/libwebsockets.so
+
+### CMake will append .so 3rd party suppressions here, unless disabled:
diff --git a/tests/lsan_3rdparty.supp b/tests/lsan_3rdparty.supp
new file mode 100644
index 0000000..c497d74
--- /dev/null
+++ b/tests/lsan_3rdparty.supp
@@ -0,0 +1,4 @@
+# 3rd party lsan suppressions
+
+leak:/libpython2.*.so
+leak:/libpython3.*.so
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org