diff options
author | Niels de Vos <ndevos@redhat.com> | 2017-02-27 22:37:00 -0800 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-04-07 13:17:12 -0400 |
commit | ef36ac0d1b72ab2c07ed6e0a3116b7265c3c0164 (patch) | |
tree | 5932e44145f713f1c986f484edc4e4388b726b72 /libglusterfs | |
parent | 40e571339b3c19ab2a5b6a93bc46eadf2252d006 (diff) |
xlator: do not call dlclose() when debugging
Valgrind can not show the symbols if a .so after calling dlclose(). The
unhelpful ??? in the output gets resolved properly with this change:
==25170== 344 bytes in 1 blocks are definitely lost in loss record 233 of 324
==25170== at 0x4C29975: calloc (vg_replace_malloc.c:711)
==25170== by 0x52C7C0B: __gf_calloc (mem-pool.c:117)
==25170== by 0x12B0638A: ???
==25170== by 0x528FCE6: __xlator_init (xlator.c:472)
==25170== by 0x528FE16: xlator_init (xlator.c:498)
==25170== by 0x52DA8D6: glusterfs_graph_init (graph.c:321)
==25170== by 0x52DB587: glusterfs_graph_activate (graph.c:695)
==25170== by 0x5046407: glfs_process_volfp (glfs-mgmt.c:79)
==25170== by 0x5043B9E: glfs_volumes_init (glfs.c:281)
==25170== by 0x5044FEC: glfs_init_common (glfs.c:986)
==25170== by 0x50451A7: glfs_init@@GFAPI_3.4.0 (glfs.c:1031)
By not calling dlclose(), the dynamically loaded .so is still available
upon program exit, and Valgrind is able to resolve the symbols. This
will add an additional leak, so dlclose() is called for normal builds,
but skipped when configuring with "./configure --enable-valgrind" or
passing the "run-with-valgrind" xlator option.
URL: http://valgrind.org/docs/manual/faq.html#faq.unhelpful
Change-Id: I2044e21b1b8fcce32ad1a817fdd795218f967731
BUG: 1425623
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: https://review.gluster.org/16809
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Samikshan Bairagya <samikshan@gmail.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/ctx.c | 4 | ||||
-rw-r--r-- | libglusterfs/src/glusterfs.h | 5 | ||||
-rw-r--r-- | libglusterfs/src/xlator.c | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/libglusterfs/src/ctx.c b/libglusterfs/src/ctx.c index b009e6270a2..d3fb39822d1 100644 --- a/libglusterfs/src/ctx.c +++ b/libglusterfs/src/ctx.c @@ -37,6 +37,10 @@ glusterfs_ctx_new () ctx->log.loglevel = DEFAULT_LOG_LEVEL; +#ifdef RUN_WITH_VALGRIND + ctx->cmd_args.valgrind = _gf_true; +#endif + /* lock is never destroyed! */ ret = LOCK_INIT (&ctx->lock); if (ret) { diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 4f1f27b5857..ce0dde22d4a 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -401,6 +401,11 @@ struct _cmd_args { #ifdef GF_LINUX_HOST_OS char *oom_score_adj; #endif + + /* Run this process with valgrind? Might want to prevent calling + * functions that prevent valgrind from working correctly, like + * dlclose(). */ + int valgrind; }; typedef struct _cmd_args cmd_args_t; diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 408012e7846..b1ed094e0ae 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -673,7 +673,7 @@ xlator_members_free (xlator_t *xl) GF_FREE (xl->name); GF_FREE (xl->type); - if (xl->dlhandle) + if (!(xl->ctx && xl->ctx->cmd_args.valgrind) && xl->dlhandle) dlclose (xl->dlhandle); if (xl->options) dict_unref (xl->options); |