From d6185733d12572f9227fcb9fe5be8b82bd43ee45 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 22 Jan 2023 14:49:27 -0500 Subject: [PATCH] lib: remove one BT_LIB_LOGD from init_error_cause MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This BT_LIB_LOGD is problematic when debug logging is enabled. It prints a half-constructed bt_error_cause object, which may cause an assertion failure, as seen here: #3 0x00007f6defd91105 in bt_common_abort () at common.c:2111 #4 0x00007f6defd995c6 in bt_common_field_class_type_string (class_type=) at ../../src/common/common.h:547 #5 format_field (field=, prefix=, extended=, buf_ch=) at lib-logging.c:366 #6 handle_conversion_specifier_bt (priv_data=priv_data@entry=0x0, buf_ch=buf_ch@entry=0x7fff0bf60d80, avail_size=, out_fmt_ch=out_fmt_ch@entry=0x7fff0bf60d78, args=args@entry=0x7fff0bf60e40) at lib-logging.c:1401 #7 0x00007f6defdcddd4 in bt_common_custom_vsnprintf (buf=0x7f6def96a740 "Initialized error cause: addr=0x55c0f6232340, actor-type=COMPONENT, module-name=\"\", partial-msg=\"\", comp-name=\"(null)\"", buf_size=16384, intro=33 '!', handle_specifier=0x7f6defd99320 , priv_data=0x0, fmt=, args=0x7fff0bf60e40) at common.c:1728 #8 0x00007f6defd9c275 in bt_lib_log_v (func=0x7f6defdd0190 <__func__.28> "init_error_cause", file=0x7f6defdcf6b0 "error.c", line=158, lvl=2, tag=0x7f6defdcf6b8 "LIB/ERROR", fmt=0x7f6defdcf6c2 "Initialized error cause: %!+r", args=0x7fff0bf60e40) at lib-logging.c:1491 #9 0x00007f6defd9c35c in bt_lib_log (func=func@entry=0x7f6defdd0190 <__func__.28> "init_error_cause", file=file@entry=0x7f6defdcf6b0 "error.c", line=line@entry=158, lvl=lvl@entry=2, tag=tag@entry=0x7f6defdcf6b8 "LIB/ERROR", fmt=fmt@entry=0x7f6defdcf6c2 "Initialized error cause: %!+r") at lib-logging.c:1503 #10 0x00007f6defd928d2 in init_error_cause (cause=cause@entry=0x55c0f6232340, actor_type=actor_type@entry=BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT) at error.c:158 #11 0x00007f6defd93296 in create_error_cause_component_actor (line_no=102, file_name=0x7f6dedfb7638 "bt2/native_bt_log_and_append_error.h", comp=0x55c0f66f18d0) at error.c:277 #12 bt_error_append_cause_from_component (error=0x55c0f66f1d10, self_comp=self_comp@entry=0x55c0f66f18d0, file_name=file_name@entry=0x7f6dedfb7638 "bt2/native_bt_log_and_append_error.h", line_no=line_no@entry=102, msg_fmt=msg_fmt@entry=0x7f6dedfb70da "%s", args=args@entry=0x7fff0bf60fa0) at error.c:512 In this specific case, the component class type value passed to bt_common_component_class_type_string is uninitialized and invalid. Remove that logging statement. Each caller already calls BT_LIB_LOGD again with the fully constructed object, so this BT_LIB_LOGD in init_error_cause would not bring anything useful anyway. Change-Id: I8a56142e6a1d70017f1a50f6c93dff623a08f3bf Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/9585 Reviewed-by: Jérémie Galarneau Tested-by: jenkins --- src/lib/error.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/error.c b/src/lib/error.c index bd8259ab..067f30db 100644 --- a/src/lib/error.c +++ b/src/lib/error.c @@ -155,8 +155,6 @@ int init_error_cause(struct bt_error_cause *cause, goto end; } - BT_LIB_LOGD("Initialized error cause: %!+r", cause); - end: return ret; } -- 2.34.1