From: Francis Deslauriers Date: Tue, 5 May 2020 15:51:58 +0000 (-0400) Subject: Fix: event probes attached before event enabled X-Git-Tag: v2.11.3~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=89909e362150f437c619f627e20bb4434a1566aa;p=lttng-ust.git Fix: event probes attached before event enabled Background ========== When userspace events with exclusions are enabled by the CLI user, the session daemon enables the events in a 3-steps process using the following ustctl commands: 1. `LTTNG_UST_EVENT` to create an event and get an handle on it, 2. `LTTNG_UST_EXCLUSION` to attach exclusions, and 3. `LTTNG_UST_ENABLE` to activate the tracing of this event. Also, the session daemon uses the `LTTNG_UST_SESSION_START` to start the tracing of events. In various use cases, this can happen before OR after the 3-steps process above. Scenario ======== If the`LTTNG_UST_SESSION_START` is done before the 3-steps process the tracer will end up not considering the exclusions and trace all events matching the event name glob pattern provided at step #1. This is due to the fact that when we do step #1, we end up calling `lttng_session_lazy_sync_enablers()`. This function will sync the event enablers if the session is active (which it is in our scenario because of the _SESSION_START). Syncing the enablers will then match event name glob patterns provided by the user to the event descriptors of the tracepoints and attach probes in their corresponding callsite on matches. All of this is done before we even received the exclusions in step #2. Problem ======= The problem is that we attach probes to tracepoints before being sure we received the entire description of the events. Step #2 may reduced the set of tracepoints to trace so we must wait until exclusions are all received to attached probes to tracepoints. Solution ======== Only match event names and exclusions (and ultimately, register probes) on enabled enablers to ensure that no other modifications will be applied to the event. Event enablers are enabled when at step #3. Note ==== Filters are not causing problems here because adding a filter won't change what tracepoints are to be traced. Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers Change-Id: Id984f266d976f346b001db81cd8a2b74965b5ef2 --- diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 19fba81c..529e33d8 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -903,6 +903,9 @@ int lttng_enabler_ref_events(struct lttng_enabler *enabler) struct lttng_session *session = enabler->chan->session; struct lttng_event *event; + if (!enabler->enabled) + goto end; + /* First ensure that probe events are created for this enabler. */ lttng_create_event_if_missing(enabler); @@ -934,6 +937,7 @@ int lttng_enabler_ref_events(struct lttng_enabler *enabler) /* TODO: merge event context. */ } +end: return 0; }