Fix: relayd: live: crash on attach to a session without trace chunk
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 29 Oct 2019 03:32:36 +0000 (23:32 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 29 Oct 2019 04:02:00 +0000 (00:02 -0400)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/live.c

index 8c4f501aa3446afd5b5cb5d7e72e42bf82dd2d11..e480f86e483400874c2240b78dfe74b46524222f 100644 (file)
@@ -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);
This page took 0.025853 seconds and 4 git commands to generate.