Gris Ge
2014-12-18 04:22:01 UTC
* When running a C plugin from code tree(mostly when coding), the
xxx_lsmplugin is actually a shell script which exec the real C plugin
as child process.
Previous code, with LSM_VALGRIND, valgrind cannot detect memory leak
of child process.
* This patch changes:
1. Enable child process memory leak check in valgrind.
2. Add '%p' to log file name which will be replaced with child PID.
This will cause multiple log file created for each plugin run, example:
/tmp/leaking_2431-2435-2435
/tmp/leaking_2431-2435-2443
/tmp/leaking_2431-2435-2447
* Considering valgrind often enabled when coding C plugin, this change will
not impact real user but saves a lot time on investigating memory leak
on C plugin(previously, you need to do manual linking and install the
binary).
Signed-off-by: Gris Ge <***@redhat.com>
---
daemon/lsm_daemon.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/daemon/lsm_daemon.c b/daemon/lsm_daemon.c
index acc8ef5..16efdd3 100644
--- a/daemon/lsm_daemon.c
+++ b/daemon/lsm_daemon.c
@@ -546,15 +546,16 @@ void exec_plugin( char *plugin, int client_fd )
if( plugin_mem_debug ) {
char debug_out[64];
snprintf(debug_out, (sizeof(debug_out) - 1),
- "--log-file=/tmp/leaking_%d-%d", getppid(), getpid());
+ "--log-file=/tmp/leaking_%d-%d-%%p", getppid(), getpid());
plugin_argv[0] = "valgrind";
plugin_argv[1] = "--leak-check=full";
plugin_argv[2] = "--show-reachable=no";
- plugin_argv[3] = debug_out;
- plugin_argv[4] = p_copy;
- plugin_argv[5] = fd_str;
- plugin_argv[6] = NULL;
+ plugin_argv[3] = "--trace-children=yes";
+ plugin_argv[4] = debug_out;
+ plugin_argv[5] = p_copy;
+ plugin_argv[6] = fd_str;
+ plugin_argv[7] = NULL;
exec_rc = execve("/usr/bin/valgrind", plugin_argv, environ);
} else {
xxx_lsmplugin is actually a shell script which exec the real C plugin
as child process.
Previous code, with LSM_VALGRIND, valgrind cannot detect memory leak
of child process.
* This patch changes:
1. Enable child process memory leak check in valgrind.
2. Add '%p' to log file name which will be replaced with child PID.
This will cause multiple log file created for each plugin run, example:
/tmp/leaking_2431-2435-2435
/tmp/leaking_2431-2435-2443
/tmp/leaking_2431-2435-2447
* Considering valgrind often enabled when coding C plugin, this change will
not impact real user but saves a lot time on investigating memory leak
on C plugin(previously, you need to do manual linking and install the
binary).
Signed-off-by: Gris Ge <***@redhat.com>
---
daemon/lsm_daemon.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/daemon/lsm_daemon.c b/daemon/lsm_daemon.c
index acc8ef5..16efdd3 100644
--- a/daemon/lsm_daemon.c
+++ b/daemon/lsm_daemon.c
@@ -546,15 +546,16 @@ void exec_plugin( char *plugin, int client_fd )
if( plugin_mem_debug ) {
char debug_out[64];
snprintf(debug_out, (sizeof(debug_out) - 1),
- "--log-file=/tmp/leaking_%d-%d", getppid(), getpid());
+ "--log-file=/tmp/leaking_%d-%d-%%p", getppid(), getpid());
plugin_argv[0] = "valgrind";
plugin_argv[1] = "--leak-check=full";
plugin_argv[2] = "--show-reachable=no";
- plugin_argv[3] = debug_out;
- plugin_argv[4] = p_copy;
- plugin_argv[5] = fd_str;
- plugin_argv[6] = NULL;
+ plugin_argv[3] = "--trace-children=yes";
+ plugin_argv[4] = debug_out;
+ plugin_argv[5] = p_copy;
+ plugin_argv[6] = fd_str;
+ plugin_argv[7] = NULL;
exec_rc = execve("/usr/bin/valgrind", plugin_argv, environ);
} else {
--
1.8.3.1
1.8.3.1