Fix: add-context cannot be performed after a session has been started
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 5 Feb 2018 23:19:00 +0000 (18:19 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 19 Feb 2018 20:11:55 +0000 (15:11 -0500)
The following scenario lead to a corrupted trace/metadata layout problem:
  - lttng create test
  - lttng enable-channel -u test
  - lttng enable-event -u -a -c test
  - lttng start
  - ./instrumented-application
  - lttng stop
  - lttng add-context -u -t procname -c test
  - lttng start
  - ./instrumented-application
  - lttng stop
  - lttng view

Babeltrace 1.5.x will fail with:

[error] Unexpected end of packet. Either the trace data stream is corrupted or metadata description does not match data layout.
[error] Reading event failed.
Error printing trace.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c

index 67b2e77f49c34ff690bf9467ad975c95c85ef59c..1a3c22a6c8f87715dc85c878ec5b0c3443d7d1e3 100644 (file)
@@ -1654,6 +1654,16 @@ int cmd_add_context(struct ltt_session *session, enum lttng_domain_type domain,
        int ret, chan_kern_created = 0, chan_ust_created = 0;
        char *app_ctx_provider_name = NULL, *app_ctx_name = NULL;
 
+       /*
+        * Don't try to add a context if the session has been started at
+        * some point in time before. The tracer does not allow it and would
+        * result in a corrupted trace.
+        */
+       if (session->has_been_started) {
+               ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
+               goto end;
+       }
+
        if (ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT) {
                app_ctx_provider_name = ctx->u.app_ctx.provider_name;
                app_ctx_name = ctx->u.app_ctx.ctx_name;
This page took 0.036203 seconds and 4 git commands to generate.