cli: fix bt_plugin leak when using `-i ctf`
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>
This page took 0.027212 seconds and 4 git commands to generate.