From: Jérémie Galarneau Date: Tue, 29 Oct 2019 03:32:36 +0000 (-0400) Subject: Fix: relayd: live: crash on attach to a session without trace chunk X-Git-Tag: v2.12.0-rc1~270 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=79a4298098da8ec2d118e00ca2a08e7b542e7287;p=lttng-tools.git Fix: relayd: live: crash on attach to a session without trace chunk Attaching to a session that doesn't have a current trace chunk results in a crash when the viewer streams are created from a NULL viewer trace chunk. Live clients are prevented from attaching to sessions without a current trace chunk as those sessions are either being destroyed or too young to have a trace chunk, meaning that they don't have streams yet. Live clients will receive the "unknown" status code that they already receive when asking an unknown session. Since such sessions are not listed, this shouldn't change any exposed behaviour. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index 8c4f501aa..e480f86e4 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -1080,6 +1080,15 @@ int viewer_attach_session(struct relay_connection *conn) DBG("Attach session ID %" PRIu64 " received", session_id); pthread_mutex_lock(&session->lock); + if (!session->current_trace_chunk) { + /* + * Session is either being destroyed or it never had a trace + * chunk created against it. + */ + DBG("Session requested by live client has no current trace chunk, returning unknown session"); + response.status = htobe32(LTTNG_VIEWER_ATTACH_UNK); + goto send_reply; + } if (session->live_timer == 0) { DBG("Not live session"); response.status = htobe32(LTTNG_VIEWER_ATTACH_NOT_LIVE);