Fix: lib: handle BT_FUNC_STATUS_NOT_FOUND in bt_plugin_so_create_all_from_sections
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 15 Jan 2024 21:24:19 +0000 (16:24 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 29 Jan 2024 16:38:19 +0000 (11:38 -0500)
commit1a9956b9616ccb5b80f6c5db4bcbe0bc38589de4
treed268dedd3b3d7bb1007b7b1b3f99dec5613a7611
parent821af09916878cc088b71e380980a75dc1017e10
Fix: lib: handle BT_FUNC_STATUS_NOT_FOUND in bt_plugin_so_create_all_from_sections

When an SO plugin's init function returns an error and
fail_on_load_error is false, we hit an assert:

    (╯°□°)╯︵ ┻━┻  /home/smarchi/src/babeltrace/src/lib/plugin/plugin-so.c:1351: bt_plugin_so_create_all_from_sections(): Assertion `!plugin` failed.

When an error happens in the plugin's init function, bt_plugin_so_init returns BT_FUNC_STATUS_NOT_FOUND.  We leave the `plugin` variable set, which triggers the assert.

Fix this by putting/resetting `plugin` in that case.  Since there was an
error initializing the plugin, we won't return it to the user, so I
think that release it is the right thing to do here.

Add a test with a plugin whose init function fail.  Test both the
fail_on_load_error true and false cases.

Change-Id: I8e219f728a4b58d0e32307f907243892a02fdccf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: Brice Videau <bvideau@anl.gov>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11679
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Brice Videau <bvideau@anl.gov>
Tested-by: jenkins <jenkins@lttng.org>
configure.ac
src/lib/plugin/plugin-so.c
tests/lib/Makefile.am
tests/lib/test-plugin-init-fail-plugin/Makefile.am [new file with mode: 0644]
tests/lib/test-plugin-init-fail-plugin/plugin-init-fail.cpp [new file with mode: 0644]
tests/lib/test-plugin-init-fail.cpp [new file with mode: 0644]
tests/lib/test-plugin-init-fail.sh [new file with mode: 0755]
This page took 0.025493 seconds and 4 git commands to generate.