From: Francis Deslauriers Date: Thu, 19 Dec 2019 21:39:45 +0000 (-0500) Subject: Fix: src.ctf.lttng-live: emitting stream end msg with no stream X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=1cda4ff4025e4b3f7bd2a861baa51d2113c4cbf9;hp=1cda4ff4025e4b3f7bd2a861baa51d2113c4cbf9;p=babeltrace.git Fix: src.ctf.lttng-live: emitting stream end msg with no stream Background ========== When a stream hangs up on the `src.ctf.lttng-live` component, we make sure we send a stream end message to ensure we honor The Contract which states that any stream beginning must eventually be followed by its stream end counterpart. We do this by calling `ctf_msg_iter_get_next_message()` one last time to emit any missing messages. Using the upcoming lttng clear feature in conjunction with a per-pid session makes it highly likely that a live stream hangs up on the `src.ctf.lttng-live` component between the moment we learn about it and the moment we first ask for its live index. In such event, the live stream iterator and its `ctf_msg_it` are both created but the corresponding stream is uninitialized. When the component realized that a live stream has hung up, it calls `ctf_msg_iter_get_next_message()` to respect The Contract but then errors out here: CAUSED BY [lttng-live: 'source.ctf.lttng-live'] (msg-iter.c:2474) Cannot create stream end message because stream is NULL: msg-it-addr=0x555fba864010 The `stream` field is null because we never got the chance to received any index for this stream. Issue ===== It's possible for a `ctf_msg` state machine to pass by the `STATE_EMIT_MSG_STREAM_END` state without having passed by the `STATE_EMIT_MSG_STREAM_BEGINNING` state. Solution ======== Keep track of the fact that we sent a stream beginning message downstream and that we need to send its respective stream end message. If no message were send for a particular stream, we can omit sending a stream end message. Signed-off-by: Francis Deslauriers Change-Id: If7f52f43162e7263785713c01c226907fe475d94 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2719 CI-Build: Simon Marchi Tested-by: jenkins Reviewed-by: Simon Marchi ---