From: Philippe Duplessis-Guindon Date: Fri, 16 Oct 2020 18:29:05 +0000 (-0400) Subject: Fix: lib: assert if an error occurs in `bt_message_iterator_class_finalize_method` X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=4fb18ad2a9fe1fe95931f1aa2960417b9e558ae2 Fix: lib: assert if an error occurs in `bt_message_iterator_class_finalize_method` 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 Change-Id: I6cf6118661cbe615c1f6ddc77c8b3555dca3b526 Reviewed-on: https://review.lttng.org/c/babeltrace/+/4201 CI-Build: Philippe Proulx Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index ccc12d61..796ade07 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -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);