Fix: lib: assert if an error occurs in `bt_message_iterator_class_finalize_method`
authorPhilippe Duplessis-Guindon <pduplessis@efficios.com>
Fri, 16 Oct 2020 18:29:05 +0000 (14:29 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 8 Feb 2021 21:05:49 +0000 (16:05 -0500)
I tried to append an error with `BT_COMP_LOGE_APPEND_CAUSE_ERRNO`
in `bt_message_iterator_class_finalize_method` from a plugin, and
there was no error. The expected behavior would be for the plugin
to fail if there is an error on the current thread after returning.

This patch adds `BT_ASSERT_POST_NO_ERROR` and the assert fails if
there is an error on the current thread after returning

With this patch, here is the following output, which is the expected behavior:
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:64 Babeltrace 2 library postcondition not satisfied.
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:66 ------------------------------------------------------------------------
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:67 Condition ID: `post:message-iterator-class-finalize-method:no-error`.
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:69 Function: bt_message_iterator_class_finalize_method().
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:70 ------------------------------------------------------------------------
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:71 Error is:
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:73 Current thread has an error
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:76 Aborting...

Add `BT_ASSERT_POST_NO_ERROR` after calling the method.

Signed-off-by: Philippe Duplessis-Guindon <pduplessis@efficios.com>
Change-Id: I6cf6118661cbe615c1f6ddc77c8b3555dca3b526
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4201
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/graph/iterator.c

index ccc12d615f9c203d5002580702c8f07317c08e16..796ade072d59c0c13b45758980a7e29b5af1fc47 100644 (file)
@@ -201,6 +201,7 @@ void bt_message_iterator_try_finalize(
                        BT_LIB_LOGD("Calling user's finalization method: %!+i",
                                iterator);
                        method(iterator);
+                       BT_ASSERT_POST_NO_ERROR("bt_message_iterator_class_finalize_method");
 
                        if (saved_error) {
                                BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(saved_error);
This page took 0.025984 seconds and 4 git commands to generate.