From 535fb48a33f404e13d8ec0c9d291b4e00d6b40c6 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Mon, 13 Jul 2020 13:43:59 -0400 Subject: [PATCH] Fix: src.ctf.lttng-live: overwrite of error status trips `BT_ASSERT()` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Issue ===== While tracking a bug in the LTTng Consumer daemon we witness an assertion failure of Babeltrace: # Test ust streaming live clear with viewer # Parameters: tracing_active=1, clear_twice=1, buffer_type=uid ok 253 - Create session Yi7ksFEZ76dwwd4m with uri:net://localhost and opts: --live ok 254 - Enable channel chan for session Yi7ksFEZ76dwwd4m ok 255 - Enable ust event tp:tptest for session Yi7ksFEZ76dwwd4m ok 256 - Start tracing for session Yi7ksFEZ76dwwd4m # Waiting for live trace at url: net://localhost ok 257 - Waiting for live trace at url: net://localhost # Waiting for live viewers on url: net://localhost ok 258 - Waiting for live viewers on url: net://localhost 07-10 15:14:20.932 13745 13745 E PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER lttng_live_get_stream_bytes@viewer-connection.c:1601 [lttng-live] Received get_data_packet response: unknown (╯°□°)╯︵ ┻━┻ msg-iter.c:491: request_medium_bytes(): Assertion `buffer_sz != 0` failed The issue is that even when the `lttng_live_get_stream_bytes()` function fails miserably because of an unknown status code, it could return a `CTF_MSG_ITER_MEDIUM_STATUS_OK`. This happens because we are calling the `viewer_status_to_ctf_msg_iter_medium_status()` function in the `error:` label even when the `status` variable was already set. Solution ======== Add another label to specifically convert status from `enum lttng_live_viewer_status` to `enum ctf_msg_iter_medium_status`. Notes ===== - This commit adds the printing of the value of the unknown status received by the Relay Signed-off-by: Francis Deslauriers Change-Id: I6c740dd28ee0b336cf06dbdbf60d6333cf79d168 Reviewed-on: https://review.lttng.org/c/babeltrace/+/3758 Reviewed-by: Jérémie Galarneau Tested-by: jenkins --- src/plugins/ctf/lttng-live/viewer-connection.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/ctf/lttng-live/viewer-connection.c b/src/plugins/ctf/lttng-live/viewer-connection.c index be9c79e0..a821431e 100644 --- a/src/plugins/ctf/lttng-live/viewer-connection.c +++ b/src/plugins/ctf/lttng-live/viewer-connection.c @@ -1551,14 +1551,14 @@ enum ctf_msg_iter_medium_status lttng_live_get_stream_bytes( if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) { viewer_handle_send_status(self_comp, NULL, viewer_status, "get data packet command"); - goto error; + goto error_convert_status; } viewer_status = lttng_live_recv(viewer_connection, &rp, sizeof(rp)); if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) { viewer_handle_recv_status(self_comp, NULL, viewer_status, "get data packet reply"); - goto error; + goto error_convert_status; } flags = be32toh(rp.flags); @@ -1599,28 +1599,28 @@ enum ctf_msg_iter_medium_status lttng_live_get_stream_bytes( goto end; default: BT_COMP_LOGE_APPEND_CAUSE(self_comp, - "Received get_data_packet response: unknown"); + "Received get_data_packet response: unknown (%d)", rp_status); status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR; - goto error; + goto end; } if (req_len == 0) { status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR; - goto error; + goto end; } viewer_status = lttng_live_recv(viewer_connection, buf, req_len); if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) { viewer_handle_recv_status(self_comp, NULL, viewer_status, "get data packet"); - goto error; + goto error_convert_status; } *recv_len = req_len; status = CTF_MSG_ITER_MEDIUM_STATUS_OK; goto end; -error: +error_convert_status: status = viewer_status_to_ctf_msg_iter_medium_status(viewer_status); end: return status; -- 2.34.1