All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] unit/test-gdbus-client: Fix memory leak
@ 2015-08-21 13:51 Luiz Augusto von Dentz
  2015-08-21 13:51 ` [PATCH BlueZ 2/3] build: Add support for running make check with valgrind Luiz Augusto von Dentz
  2015-08-21 13:51 ` [PATCH BlueZ 3/3] shared/tester: Add valgrind support Luiz Augusto von Dentz
  0 siblings, 2 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-08-21 13:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The following memory leak is causes if not all interfaces are freed
once closing the connecting:

7,738 (232 direct, 7,506 indirect) bytes in 1 blocks are definitely lost in loss record 302 of 302
       at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x519517F: ??? (in /usr/lib64/libdbus-1.so.3.8.13)
       by 0x519EF8E: ??? (in /usr/lib64/libdbus-1.so.3.8.13)
       by 0x519F462: ??? (in /usr/lib64/libdbus-1.so.3.8.13)
       by 0x5193419: ??? (in /usr/lib64/libdbus-1.so.3.8.13)
       by 0x517E6AE: ??? (in /usr/lib64/libdbus-1.so.3.8.13)
       by 0x517A06B: ??? (in /usr/lib64/libdbus-1.so.3.8.13)
       by 0x4076B9: g_dbus_setup_private (mainloop.c:314)
       by 0x404B8C: client_force_disconnect (test-gdbus-client.c:882)
       by 0x410B52: run_callback (tester.c:417)
       by 0x4E7EA89: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4400.1)
       by 0x4E7EE1F: ??? (in /usr/lib64/libglib-2.0.so.0.4400.1)
---
 unit/test-gdbus-client.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index b25289f..dd17c00 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -861,6 +861,10 @@ static void proxy_force_disconnect(GDBusProxy *proxy, void *user_data)
 	context->timeout_source = g_timeout_add_seconds(2, timeout_test,
 								context);
 
+	g_dbus_detach_object_manager(conn);
+
+	g_dbus_unregister_interface(conn, SERVICE_PATH, SERVICE_NAME1);
+
 	dbus_connection_flush(conn);
 	dbus_connection_close(conn);
 	dbus_connection_unref(conn);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ 2/3] build: Add support for running make check with valgrind
  2015-08-21 13:51 [PATCH BlueZ 1/3] unit/test-gdbus-client: Fix memory leak Luiz Augusto von Dentz
@ 2015-08-21 13:51 ` Luiz Augusto von Dentz
  2015-08-21 13:51 ` [PATCH BlueZ 3/3] shared/tester: Add valgrind support Luiz Augusto von Dentz
  1 sibling, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-08-21 13:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This check if valgrind tool is available adding it to be run with make
check.
---
 Makefile.am   |  6 ++++++
 configure.ac  |  3 +++
 valgrind.supp | 14 ++++++++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 valgrind.supp

diff --git a/Makefile.am b/Makefile.am
index 3df694c..90e1209 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -428,6 +428,12 @@ if DBUS_RUN_SESSION
 AM_TESTS_ENVIRONMENT += dbus-run-session --
 endif
 
+if VALGRIND
+LOG_COMPILER = valgrind --error-exitcode=1 --num-callers=30
+LOG_FLAGS = --trace-children=yes --leak-check=full --show-reachable=no \
+		--suppressions=$(srcdir)/valgrind.supp --quiet
+endif
+
 pkgconfigdir = $(libdir)/pkgconfig
 
 if LIBRARY
diff --git a/configure.ac b/configure.ac
index 8ea503c..9b766fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,9 +35,12 @@ AC_PROG_LIBTOOL
 if (test "$USE_MAINTAINER_MODE" = "yes"); then
 	AC_CHECK_PROG(enable_coverage, [lcov], [yes], [no])
 	AC_CHECK_PROG(enable_dbus_run_session, [dbus-run-session], [yes])
+	AC_CHECK_PROG(enable_valgrind, [valgrind], [yes])
+	AC_CHECK_HEADERS(valgrind/memcheck.h)
 fi
 AM_CONDITIONAL(COVERAGE, test "${enable_coverage}" = "yes")
 AM_CONDITIONAL(DBUS_RUN_SESSION, test "${enable_dbus_run_session}" = "yes")
+AM_CONDITIONAL(VALGRIND, test "${enable_dbus_run_session}" = "yes")
 
 MISC_FLAGS
 
diff --git a/valgrind.supp b/valgrind.supp
new file mode 100644
index 0000000..bf28bcd
--- /dev/null
+++ b/valgrind.supp
@@ -0,0 +1,14 @@
+{
+   ecb_bind
+   Memcheck:Param
+   socketcall.bind(my_addr.sa_data)
+   fun:bind
+   fun:ecb_aes_setup
+}
+{
+   cmac_bind
+   Memcheck:Param
+   socketcall.bind(my_addr.sa_data)
+   fun:bind
+   fun:cmac_aes_setup
+}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ 3/3] shared/tester: Add valgrind support
  2015-08-21 13:51 [PATCH BlueZ 1/3] unit/test-gdbus-client: Fix memory leak Luiz Augusto von Dentz
  2015-08-21 13:51 ` [PATCH BlueZ 2/3] build: Add support for running make check with valgrind Luiz Augusto von Dentz
@ 2015-08-21 13:51 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-08-21 13:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This add a call to VALGRIND_DO_ADDED_LEAK_CHECK at the end of each test.
---
 src/shared/tester.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/shared/tester.c b/src/shared/tester.c
index 30857e0..c3120fb 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -35,6 +35,10 @@
 
 #include <glib.h>
 
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
+
 #include "src/shared/util.h"
 #include "src/shared/tester.h"
 
@@ -339,6 +343,10 @@ static gboolean teardown_callback(gpointer user_data)
 	print_progress(test->name, COLOR_MAGENTA, "teardown");
 	test->teardown_func(test->test_data);
 
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+	VALGRIND_DO_ADDED_LEAK_CHECK;
+#endif
+
 	return FALSE;
 }
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ 3/3] shared/tester: Add valgrind support
  2015-08-21 14:01 [PATCH BlueZ 1/3] unit/test-gdbus-client: Fix memory leak Luiz Augusto von Dentz
@ 2015-08-21 14:01 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2015-08-21 14:01 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This add a call to VALGRIND_DO_ADDED_LEAK_CHECK at the end of each test.
---
 src/shared/tester.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/shared/tester.c b/src/shared/tester.c
index 30857e0..c3120fb 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -35,6 +35,10 @@
 
 #include <glib.h>
 
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
+
 #include "src/shared/util.h"
 #include "src/shared/tester.h"
 
@@ -339,6 +343,10 @@ static gboolean teardown_callback(gpointer user_data)
 	print_progress(test->name, COLOR_MAGENTA, "teardown");
 	test->teardown_func(test->test_data);
 
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+	VALGRIND_DO_ADDED_LEAK_CHECK;
+#endif
+
 	return FALSE;
 }
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-21 14:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-21 13:51 [PATCH BlueZ 1/3] unit/test-gdbus-client: Fix memory leak Luiz Augusto von Dentz
2015-08-21 13:51 ` [PATCH BlueZ 2/3] build: Add support for running make check with valgrind Luiz Augusto von Dentz
2015-08-21 13:51 ` [PATCH BlueZ 3/3] shared/tester: Add valgrind support Luiz Augusto von Dentz
2015-08-21 14:01 [PATCH BlueZ 1/3] unit/test-gdbus-client: Fix memory leak Luiz Augusto von Dentz
2015-08-21 14:01 ` [PATCH BlueZ 3/3] shared/tester: Add valgrind support Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.