summaryrefslogtreecommitdiff
path: root/Makefile.am
diff options
context:
space:
mode:
authorKota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>2017-02-15 01:08:25 -0800
committerKota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>2017-02-20 07:45:55 -0800
commitc9136a62b6e7cc8701cd7206ef0367520a20b8b9 (patch)
treee3710b1997b9fce5128809ee3437724432240979 /Makefile.am
parent10e096fe097a489eec41bad120f5b5e52fa4b61c (diff)
downloadliberasurecode-c9136a62b6e7cc8701cd7206ef0367520a20b8b9.tar.gz
Fix valgrind-check and memory leak
Can you believe that we ware testing the memory leak with valgrind to just *bash scripts* instead of actual binaries on liberasurecode_test and libec_slap? That is why we cannot find such an easy memory leak[1] at the gate. Now this patch enable to run the valgrind against to the binaries. With this fix, we found various memory leak at liberasurecode_test as follows and this patch also fixes them: - If we create fake fragments, we're responsible for freeing all of the frags as well as the array holding the pointers to the frags. - If we allocate any space, we're responsible for freeing it. - If we create an EC descriptor, we're responsible for destroying it. - If we create a fragment or skip array, we're responsible for freeing it. - If that happens inside a loop, we're responsible for doing it *inside that same loop*. In addition to the test fix, this patch fixes following memory leaks at the code which is affected to other users (pyeclib, OpenStack Swift) * Refuse to decode fragments that aren't even long enough to include fragment headers. * Fix a small memory leak in the builtin rs_vand implementation. Closes-Bug: #1665242 Co-Authored-By: Tim Burke <tim@swiftstack.com> 1: https://review.openstack.org/#/c/431812 Change-Id: I96f124e4e536bbd7544208acc084de1cda5c19b2
Diffstat (limited to 'Makefile.am')
-rw-r--r--Makefile.am19
1 files changed, 14 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am
index 5f6fb9b..f52e046 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,13 +62,22 @@ test: check
VALGRIND_EXEC_COMMAND = $(LIBTOOL_COMMAND) valgrind --tool=memcheck \
--error-exitcode=1 --leak-check=yes --track-fds=yes \
- --malloc-fill=A5 --free-fill=DE --fullpath-after=.
+ --malloc-fill=A5 --free-fill=DE --fullpath-after=. --trace-children=yes
valgrind-test: check
- @$(VALGRIND_EXEC_COMMAND) ./test/alg_sig_test
- @$(VALGRIND_EXEC_COMMAND) ./test/liberasurecode_test
- @$(VALGRIND_EXEC_COMMAND) ./test/test_xor_hd_code
- @$(VALGRIND_EXEC_COMMAND) ./test/libec_slap
+ $(eval SONAMES := $(shell find $(abs_top_builddir) -name '*.so'))
+ $(eval SODIRS := $(dir $(SONAMES)))
+ $(eval LD_LIBRARY_PATH := LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(subst / ,/:,$(SODIRS))")
+ $(eval DYLD_LIBRARY_PATH := DYLD_LIBRARY_PATH="$(DYLD_LIBRARY_PATH):$(subst / ,/:,$(SODIRS))")
+ $(eval DYLD_FALLBACK_LIBRARY_PATH := DYLD_FALLBACK_LIBRARY_PATH=$(DYLD_FALLBACK_LIBRARY_PATH):"$(subst / ,/:,$(SODIRS))")
+ @$(LD_LIBRARY_PATH) $(DYLD_LIBRARY_PATH) $(DYLD_FALLBACK_LIBRARY_PATH) $(VALGRIND_EXEC_COMMAND) \
+ ./test/alg_sig_test
+ @$(LD_LIBRARY_PATH) $(DYLD_LIBRARY_PATH) $(DYLD_FALLBACK_LIBRARY_PATH) $(VALGRIND_EXEC_COMMAND) \
+ ./test/.libs/liberasurecode_test
+ @$(LD_LIBRARY_PATH) $(DYLD_LIBRARY_PATH) $(DYLD_FALLBACK_LIBRARY_PATH) $(VALGRIND_EXEC_COMMAND) \
+ ./test/test_xor_hd_code
+ @$(LD_LIBRARY_PATH) $(DYLD_LIBRARY_PATH) $(DYLD_FALLBACK_LIBRARY_PATH) $(VALGRIND_EXEC_COMMAND) \
+ ./test/.libs/libec_slap
CLEANFILES = cscope.in.out cscope.out cscope.po.out