From: Jonathan Rajotte Date: Mon, 13 Sep 2021 20:49:48 +0000 (-0400) Subject: Fix: sessiond: ust session is inactive during ust_app_global_update X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8f4456a81185bd5c97cac55114a2888a194ca42f;p=lttng-tools.git Fix: sessiond: ust session is inactive during ust_app_global_update Observed issue ============== The following scenario leads to an abort of lttng-sessiond. lttng-sessiond (with kernel tracing available) lttng create system-trace --snapshot -U /tmp/snapshot lttng enable-channel -k system-trace --subbuf-size=4k --num-subbuf=256 lttng enable-event -c system-trace -k 'sched_wak*' -s system-trace lttng start system-trace lttng enable-event -u -a Fails as expected with: Error: Events: The command tried to enable an event in a new domain for a session that has already been started once. (channel channel0, session system-trace) Launch any ust app such as easy_ust from the lttng-ust repository. The following backtrace is generated: (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007ffff7af0859 in __GI_abort () at abort.c:79 #2 0x00007ffff7af0729 in __assert_fail_base (fmt=0x7ffff7c86588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55555564b765 "usess->active", file=0x555555649a60 "ust-app.c", line #3 0x00007ffff7b01f36 in __GI___assert_fail (assertion=0x55555564b765 "usess->active", file=0x555555649a60 "ust-app.c", line=5123, function=0x55555564ecf0 <__PRETTY_FUNCTION__.14199> "ust_ #4 0x00005555555d1f5e in ust_app_global_update (usess=0x7fffe001fb90, app=0x7fffac000b80) at ust-app.c:5123 #5 0x00005555555b60d4 in update_ust_app (app_sock=82) at dispatch.c:71 #6 0x00005555555b7025 in thread_dispatch_ust_registration (data=0x5555556a07f0) at dispatch.c:409 #7 0x00005555555ad5ab in launch_thread (data=0x5555556a0810) at thread.c:65 #8 0x00007ffff7ce6609 in start_thread (arg=) at pthread_create.c:477 #9 0x00007ffff7bed293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 This also happens for the track command. You can replace the `lttng enable-event -u -a` with `lttng track --userspace --vuid=0` then launch an app and the same backtrace gets generated. Cause ===== During `process_client_msg` the `create_ust_session` function is called and a ust session is assigned to the "system_trace" session with a state of `active` set to 0 (false). This is not a problem. The problem seems to lie with a single call site for `ust_app_global_update` in `update_ust_app`. The status of the ust session is not checked before calling the `ust_app_global_update`. It is important to note that all `ust_app_global_update_all` callsites guard the call with a check against the status of the session. Solution ======== Guard the call to `ust_app_global_update` with a check of the ust session active state. Known drawbacks ========= None. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I14d25d99d0609689247cdfa86130bd0219613581 --- diff --git a/src/bin/lttng-sessiond/dispatch.c b/src/bin/lttng-sessiond/dispatch.c index 5777b3b85..ab6c34846 100644 --- a/src/bin/lttng-sessiond/dispatch.c +++ b/src/bin/lttng-sessiond/dispatch.c @@ -67,7 +67,8 @@ static void update_ust_app(int app_sock) continue; } session_lock(sess); - if (!sess->active || !sess->ust_session) { + if (!sess->active || !sess->ust_session || + !sess->ust_session->active) { goto unlock_session; }