Skip to content

Commit edbb378

Browse files
committed
Add valgrind target to check for memory leaks
Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent ed0f6ed commit edbb378

File tree

5 files changed

+61
-2
lines changed

5 files changed

+61
-2
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Infrastructure:
2626
* Remove distclean.sh in favor of make clean
2727
* Use `package`, `depends`, `install_requires` in setup.py
2828
* Add make target for scan-build (static analysis using clang)
29+
* Add make target and suppression file for Valgrind (memory checker)
2930

3031
Modules/
3132
* Remove unused LDAPberval helper functions

Doc/contributing.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ We use several specialized tools for debugging and maintenance.
168168
Make targets
169169
------------
170170

171-
``make lcov-open``
171+
``make lcov lcov-open``
172172
Generate and view test coverage for C code.
173173
Requires ``make`` and ``lcov``.
174174

175175
``make scan-build``
176176
Run static analysis. Requires ``clang``.
177177

178+
``make valgrind``
179+
Run Valgrind to check for memory leaks. Requires ``valgrind``
178180

179181
Reference leak tests
180182
--------------------

Doc/spelling_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,6 @@ userApplications
150150
userPassword
151151
usr
152152
uuids
153+
Valgrind
153154
whitespace
154155
workflow

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ LCOV_REPORT=build/lcov_report
44
LCOV_REPORT_OPTIONS=--show-details -no-branch-coverage \
55
--title "python-ldap LCOV report"
66
SCAN_REPORT=build/scan_report
7+
PYTHON_SUPP=/usr/share/doc/python3-devel/valgrind-python.supp
78

89
.NOTPARALLEL:
910

@@ -18,6 +19,9 @@ clean:
1819
-delete
1920
find . -depth -name __pycache__ -exec rm -rf {} \;
2021

22+
build:
23+
mkdir -p build
24+
2125
# LCOV report (measuring test coverage for C code)
2226
.PHONY: lcov-clean lcov-coverage lcov-report lcov-open lcov
2327
lcov-clean:
@@ -27,7 +31,7 @@ lcov-clean:
2731
lcov-coverage:
2832
WITH_GCOV=1 tox -e py27,py36
2933

30-
$(LCOV_INFO):
34+
$(LCOV_INFO): build
3135
lcov --capture --directory build --output-file $(LCOV_INFO)
3236

3337
$(LCOV_REPORT): $(LCOV_INFO)
@@ -49,3 +53,13 @@ scan-build:
4953
scan-build -o $(SCAN_REPORT) --html-title="python-ldap scan report" \
5054
-analyze-headers --view \
5155
$(PYTHON) setup.py clean --all build
56+
57+
# valgrind memory checker
58+
.PHONY: valgrind
59+
valgrind: build
60+
valgrind --leak-check=full \
61+
--suppressions=$(PYTHON_SUPP) \
62+
--suppressions=Misc/python-ldap.supp \
63+
--gen-suppressions=all \
64+
--log-file=build/valgrind.log \
65+
$(PYTHON) setup.py test

Misc/python-ldap.supp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Valgrind suppression file for Python 3.6.
2+
3+
{
4+
Ignore libldap memory leak, https://github.com/python-ldap/python-ldap/issues/82
5+
Memcheck:Leak
6+
match-leak-kinds: definite
7+
fun:malloc
8+
fun:ber_memalloc_x
9+
fun:ber_flatten
10+
fun:ldap_cancel
11+
fun:l_ldap_cancel
12+
...
13+
}
14+
15+
{
16+
Known leak in SASL interaction, https://github.com/python-ldap/python-ldap/issues/81
17+
Memcheck:Leak
18+
match-leak-kinds: definite
19+
fun:malloc
20+
fun:strdup
21+
fun:interaction
22+
fun:py_ldap_sasl_interaction
23+
fun:ldap_int_sasl_bind
24+
fun:ldap_sasl_interactive_bind
25+
fun:ldap_sasl_interactive_bind_s
26+
fun:l_ldap_sasl_interactive_bind_s
27+
...
28+
}
29+
30+
{
31+
Ignore possible leaks in exception initialization
32+
Memcheck:Leak
33+
match-leak-kinds: possible
34+
fun:malloc
35+
fun:PyObject_Malloc
36+
...
37+
fun:PyErr_NewException
38+
fun:LDAPinit_constants
39+
fun:init_ldap_module
40+
...
41+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy