lib: remove one BT_LIB_LOGD from init_error_cause
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 22 Jan 2023 19:49:27 +0000 (14:49 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 7 Mar 2023 16:23:40 +0000 (11:23 -0500)
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=<optimized out>) at ../../src/common/common.h:547
    #5  format_field (field=<optimized out>, prefix=<optimized out>, extended=<optimized out>, buf_ch=<optimized out>) at lib-logging.c:366
    #6  handle_conversion_specifier_bt (priv_data=priv_data@entry=0x0, buf_ch=buf_ch@entry=0x7fff0bf60d80, avail_size=<optimized out>, 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 <handle_conversion_specifier_bt>, priv_data=0x0,
        fmt=<optimized out>, 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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9585
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/lib/error.c

index bd8259ab71057103385d75b711ffd59a5508007a..067f30dbd73c52ccfa3b7b1203cfbfd38f635fa7 100644 (file)
@@ -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;
 }
This page took 0.025925 seconds and 4 git commands to generate.