X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fplugin%2Fplugin-so.c;h=4c390b76e53f8d15067876d8c41d6274732d9707;hb=f1447220f7e29c0eeedd90c3f3bc758125fa1b10;hp=ab2f486078e9930b18416df0150e55270c313adf;hpb=94cf822ec0adbb6d6d33d6475c5b58e1dd7e2b79;p=babeltrace.git diff --git a/lib/plugin/plugin-so.c b/lib/plugin/plugin-so.c index ab2f4860..4c390b76 100644 --- a/lib/plugin/plugin-so.c +++ b/lib/plugin/plugin-so.c @@ -138,10 +138,24 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj) } if (shared_lib_handle->module) { - if (!g_module_close(shared_lib_handle->module)) { - printf_error("Module close error: %s\n", - g_module_error()); +#ifndef NDEBUG + /* + * Valgrind shows incomplete stack traces when + * dynamically loaded libraries are closed before it + * finishes. Use the BABELTRACE_NO_DLCLOSE in a debug + * build to avoid this. + */ + const char *var = getenv("BABELTRACE_NO_DLCLOSE"); + + if (!var || strcmp(var, "1") != 0) { +#endif + if (!g_module_close(shared_lib_handle->module)) { + printf_error("Module close error: %s\n", + g_module_error()); + } +#ifndef NDEBUG } +#endif } if (shared_lib_handle->path) {