plugin-so.c: use BABELTRACE_NO_DLCLOSE env. var. to avoid dlclose()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 May 2017 07:05:55 +0000 (03:05 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:44 +0000 (12:57 -0400)
See new comment in plugin-so.c.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/plugin/plugin-so.c

index ab2f486078e9930b18416df0150e55270c313adf..4c390b76e53f8d15067876d8c41d6274732d9707 100644 (file)
@@ -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) {
This page took 0.026214 seconds and 4 git commands to generate.