From 5151d412776822cdcc8dc12d29137769c8f95a39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 3 Feb 2020 17:33:28 -0500 Subject: [PATCH] Fix: sessiond: snapshot errors don't clear session's trace chunk MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The snapshot record command is implemented by creating and setting a new trace chunk on the target session, capturing the snapshot, and closing the session's trace chunk once it is complete. On some error paths, the session's newly created trace chunk is not cleared. This means that the session is seen to have a 'current_trace_chunk' on the next attempt to record a snapshot; an unexpected condition for which an assert() exists. This results in the following crash: lttng-sessiond: /home/smarchi/src/lttng-tools/src/bin/lttng-sessiond/cmd.c:4685: snapshot_record: Assertion `!session->current_trace_chunk' failed. Ensure that the session's current trace chunk is closed and cleared when an error occurs during the command's execution. Signed-off-by: Jérémie Galarneau Change-Id: I4f78e3c324bee873349ed5b4d8e189a000458a07 --- src/bin/lttng-sessiond/cmd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 139133210..5e522d6fe 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -4687,7 +4687,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, snapshot_output->max_size); if (nb_packets_per_stream < 0) { ret_code = LTTNG_ERR_MAX_SIZE_INVALID; - goto error; + goto error_close_trace_chunk; } if (session->kernel_session) { @@ -4695,7 +4695,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, snapshot_kernel_consumer_output, session, wait, nb_packets_per_stream); if (ret_code != LTTNG_OK) { - goto error; + goto error_close_trace_chunk; } } @@ -4704,10 +4704,11 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, snapshot_ust_consumer_output, session, wait, nb_packets_per_stream); if (ret_code != LTTNG_OK) { - goto error; + goto error_close_trace_chunk; } } +error_close_trace_chunk: if (session_set_trace_chunk(session, NULL, &snapshot_trace_chunk)) { ERR("Failed to release the current trace chunk of session \"%s\"", session->name); -- 2.34.1