[lttng-dev] [PATCH babeltrace] Fix: don't access missing ctf trace when getting metadata

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Mon Aug 17 19:53:44 EDT 2015


We can get metadata when still in the trace open functions, in which
case the ctf trace is now allocated nor available yet. This fixes a
segmentation fault in stress-test.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 formats/lttng-live/lttng-live-comm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c
index 9b409bc..57586a1 100644
--- a/formats/lttng-live/lttng-live-comm.c
+++ b/formats/lttng-live/lttng-live-comm.c
@@ -600,6 +600,11 @@ int append_metadata(struct lttng_live_ctx *ctx,
 	struct lttng_live_viewer_stream *metadata;
 	char *metadata_buf = NULL;
 
+	if (!viewer_stream->ctf_trace->handle) {
+		printf_verbose("append_metadata: trace handle not ready yet.\n");
+		return 0;
+	}
+
 	printf_verbose("get_next_index: new metadata needed\n");
 	ret = get_new_metadata(ctx, viewer_stream, &metadata_buf);
 	if (ret < 0) {
-- 
2.1.4




More information about the lttng-dev mailing list