summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d7ec6b8)
When running:
libtool --mode=execute valgrind --leak-check=full ./src/cli/babeltrace2 /home/smarchi/src/babeltrace/tests/data/ctf-traces/succeed/succeed1 -i ctf
I get:
2,680 (168 direct, 2,512 indirect) bytes in 1 blocks are definitely lost in loss record 56 of 58
at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x5360B10: g_malloc0 (gmem.c:129)
by 0x4E97502: bt_plugin_create_empty (plugin.h:178)
by 0x4E9AD72: bt_plugin_so_create_empty (plugin-so.c:1239)
by 0x4E9B0D1: bt_plugin_so_create_all_from_sections (plugin-so.c:1342)
by 0x4E9BFBF: bt_plugin_so_create_all_from_file (plugin-so.c:1678)
by 0x4E93FB4: bt_plugin_find_all_from_file (plugin.c:210)
by 0x4E95300: nftw_append_all_from_dir (plugin.c:551)
by 0x5956F13: process_entry (ftw.c:464)
by 0x59573BA: ftw_dir (ftw.c:543)
by 0x5957BEB: ftw_startup (ftw.c:768)
by 0x4E95748: bt_plugin_create_append_all_from_dir (plugin.c:641)
The call to find_loaded_plugin at babeltrace2-cfg-cli-args.c:4013
returns a new reference to the plugin, for which we don't have a
corresponding put_ref.
Looking at all the users of find_loaded_plugin, they only really need to
borrow the plugin, so rather than add a put_ref, I've made it so
find_loaded_plugin returns a borrowed reference instead of a new
reference. For clarity, I've renamed that function to
borrow_loaded_plugin_by_name. And for consistency, I've renamed
borrow_loaded_plugin to borrow_loaded_plugin_by_index.
Change-Id: I19234bda6e219efa3e55da760846d138c381fac4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: Valgrind Memcheck
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2731
Tested-by: jenkins <jenkins@lttng.org>
if (auto_source_discovery_restrict_plugin_name) {
plugin_count = 1;
if (auto_source_discovery_restrict_plugin_name) {
plugin_count = 1;
- plugin = find_loaded_plugin(auto_source_discovery_restrict_plugin_name);
+ plugin = borrow_loaded_plugin_by_name(auto_source_discovery_restrict_plugin_name);
plugins = &plugin;
} else {
plugin_count = get_loaded_plugins_count();
plugins = &plugin;
} else {
plugin_count = get_loaded_plugins_count();
g_ptr_array_free(loaded_plugins, TRUE);
}
g_ptr_array_free(loaded_plugins, TRUE);
}
-const bt_plugin *find_loaded_plugin(const char *name)
+const bt_plugin *borrow_loaded_plugin_by_name(const char *name)
{
int i;
const bt_plugin *plugin = NULL;
{
int i;
const bt_plugin *plugin = NULL;
BT_LOGI("Cannot find plugin: name=\"%s\"", name);
}
BT_LOGI("Cannot find plugin: name=\"%s\"", name);
}
- bt_plugin_get_ref(plugin);
return (const bt_plugin **) loaded_plugins->pdata;
}
return (const bt_plugin **) loaded_plugins->pdata;
}
-const bt_plugin *borrow_loaded_plugin(size_t index)
+const bt_plugin *borrow_loaded_plugin_by_index(size_t index)
{
BT_ASSERT(index < loaded_plugins->len);
return g_ptr_array_index(loaded_plugins, index);
{
BT_ASSERT(index < loaded_plugins->len);
return g_ptr_array_index(loaded_plugins, index);
const bt_plugin *plugin =
bt_plugin_set_borrow_plugin_by_index_const(plugin_set, i);
const bt_plugin *loaded_plugin =
const bt_plugin *plugin =
bt_plugin_set_borrow_plugin_by_index_const(plugin_set, i);
const bt_plugin *loaded_plugin =
- find_loaded_plugin(bt_plugin_get_name(plugin));
+ borrow_loaded_plugin_by_name(bt_plugin_get_name(plugin));
bt_plugin_get_name(plugin),
bt_plugin_get_path(plugin),
bt_plugin_get_path(loaded_plugin));
bt_plugin_get_name(plugin),
bt_plugin_get_path(plugin),
bt_plugin_get_path(loaded_plugin));
- bt_plugin_put_ref(loaded_plugin);
} else {
/* Add to global array. */
BT_LOGD("Adding plugin to loaded plugins: plugin-path=\"%s\"",
} else {
/* Add to global array. */
BT_LOGD("Adding plugin to loaded plugins: plugin-path=\"%s\"",
BT_HIDDEN int require_loaded_plugins(const bt_value *plugin_paths);
BT_HIDDEN int require_loaded_plugins(const bt_value *plugin_paths);
-BT_HIDDEN const bt_plugin *find_loaded_plugin(const char *name);
BT_HIDDEN size_t get_loaded_plugins_count(void);
BT_HIDDEN const bt_plugin **borrow_loaded_plugins(void);
BT_HIDDEN size_t get_loaded_plugins_count(void);
BT_HIDDEN const bt_plugin **borrow_loaded_plugins(void);
-BT_HIDDEN const bt_plugin *borrow_loaded_plugin(size_t index);
+BT_HIDDEN const bt_plugin *borrow_loaded_plugin_by_index(size_t index);
+BT_HIDDEN const bt_plugin *borrow_loaded_plugin_by_name(const char *name);
+
#endif /* CLI_BABELTRACE_PLUGINS_H */
#endif /* CLI_BABELTRACE_PLUGINS_H */
BT_LOGI("Finding component class: plugin-name=\"%s\", "
"comp-cls-name=\"%s\"", plugin_name, comp_class_name);
BT_LOGI("Finding component class: plugin-name=\"%s\", "
"comp-cls-name=\"%s\"", plugin_name, comp_class_name);
- plugin = find_loaded_plugin(plugin_name);
+ plugin = borrow_loaded_plugin_by_name(plugin_name);
if (!plugin) {
goto end;
}
comp_class = plugin_borrow_comp_cls_func(plugin, comp_class_name);
bt_object_get_ref(comp_class);
if (!plugin) {
goto end;
}
comp_class = plugin_borrow_comp_cls_func(plugin, comp_class_name);
bt_object_get_ref(comp_class);
- BT_PLUGIN_PUT_REF_AND_RESET(plugin);
const bt_plugin *plugin = NULL;
const bt_component_class *needed_comp_cls = NULL;
const bt_plugin *plugin = NULL;
const bt_component_class *needed_comp_cls = NULL;
- plugin = find_loaded_plugin(cfg->cmd_data.help.cfg_component->plugin_name->str);
+ plugin = borrow_loaded_plugin_by_name(cfg->cmd_data.help.cfg_component->plugin_name->str);
if (!plugin) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find plugin: plugin-name=\"%s\"",
if (!plugin) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find plugin: plugin-name=\"%s\"",
end:
bt_component_class_put_ref(needed_comp_cls);
end:
bt_component_class_put_ref(needed_comp_cls);
- bt_plugin_put_ref(plugin);
}
for (i = 0; i < plugins_count; i++) {
}
for (i = 0; i < plugins_count; i++) {
- const bt_plugin *plugin = borrow_loaded_plugin(i);
+ const bt_plugin *plugin = borrow_loaded_plugin_by_index(i);
component_classes_count +=
bt_plugin_get_source_component_class_count(plugin) +
component_classes_count +=
bt_plugin_get_source_component_class_count(plugin) +
bt_common_color_reset());
for (i = 0; i < plugins_count; i++) {
bt_common_color_reset());
for (i = 0; i < plugins_count; i++) {
- const bt_plugin *plugin = borrow_loaded_plugin(i);
+ const bt_plugin *plugin = borrow_loaded_plugin_by_index(i);
printf("\n");
print_plugin_info(plugin);
printf("\n");
print_plugin_info(plugin);