Fix: src.ctf.lttng-live: overwrite of error status trips `BT_ASSERT()`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Mon, 13 Jul 2020 17:43:59 +0000 (13:43 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 21 Jul 2020 20:39:36 +0000 (16:39 -0400)
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 <francis.deslauriers@efficios.com>
Change-Id: I6c740dd28ee0b336cf06dbdbf60d6333cf79d168
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3758
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/lttng-live/viewer-connection.c

index be9c79e0035347660c98be2ef013b23a29c52f85..a821431e07624ca59c584c9d9bd8cbc5f7047fca 100644 (file)
@@ -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;
This page took 0.026939 seconds and 4 git commands to generate.