From: David Goulet Date: Fri, 7 Dec 2012 17:05:24 +0000 (-0500) Subject: Fix: check ht_del ret value of ust app session X-Git-Tag: v2.1.0~78 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=c4a1715b6c7b500eac97e149b3994a877f3023bb;ds=sidebyside Fix: check ht_del ret value of ust app session UST app sesion can be destroyed by two execution paths. Either the app unregisters or a destroy session is triggered. So, allowing a ht_del to fail means that the session is already scheduled for teardown in a rcu call. Furthermore, this means that when looking up for a ust app session that is not found becomes valid since it means it is in the teardown process. Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index c81f6e8f5..ec6f998bb 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -269,7 +269,10 @@ void delete_ust_app(struct ust_app *app) cds_lfht_for_each_entry(app->sessions->ht, &iter.iter, ua_sess, node.node) { ret = lttng_ht_del(app->sessions, &iter); - assert(!ret); + if (ret) { + /* The session is already scheduled for teardown. */ + continue; + } delete_ust_app_session(app->sock, ua_sess); } lttng_ht_destroy(app->sessions); @@ -1964,8 +1967,10 @@ int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, continue; } ua_sess = lookup_session_by_app(usess, app); - /* If ua_sess is NULL, there is a code flow error */ - assert(ua_sess); + if (!ua_sess) { + /* The application has problem or is probably dead. */ + continue; + } /* Lookup channel in the ust app session */ lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter); @@ -2087,8 +2092,10 @@ int ust_app_enable_event_glb(struct ltt_ust_session *usess, continue; } ua_sess = lookup_session_by_app(usess, app); - /* If ua_sess is NULL, there is a code flow error */ - assert(ua_sess); + if (!ua_sess) { + /* The application has problem or is probably dead. */ + continue; + } /* Lookup channel in the ust app session */ lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter); @@ -2147,8 +2154,10 @@ int ust_app_create_event_glb(struct ltt_ust_session *usess, continue; } ua_sess = lookup_session_by_app(usess, app); - /* If ua_sess is NULL, there is a code flow error */ - assert(ua_sess); + if (!ua_sess) { + /* The application has problem or is probably dead. */ + continue; + } /* Lookup channel in the ust app session */ lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter); @@ -2442,7 +2451,11 @@ int ust_app_destroy_trace(struct ltt_ust_session *usess, struct ust_app *app) } ua_sess = caa_container_of(node, struct ust_app_session, node); ret = lttng_ht_del(app->sessions, &iter); - assert(!ret); + if (ret) { + /* Already scheduled for teardown. */ + goto end; + } + obj.handle = ua_sess->handle; obj.shm_fd = -1; obj.wait_fd = -1; @@ -2716,8 +2729,10 @@ int ust_app_enable_event_pid(struct ltt_ust_session *usess, } ua_sess = lookup_session_by_app(usess, app); - /* If ua_sess is NULL, there is a code flow error */ - assert(ua_sess); + if (!ua_sess) { + /* The application has problem or is probably dead. */ + goto error; + } /* Lookup channel in the ust app session */ lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter); @@ -2777,8 +2792,10 @@ int ust_app_disable_event_pid(struct ltt_ust_session *usess, } ua_sess = lookup_session_by_app(usess, app); - /* If ua_sess is NULL, there is a code flow error */ - assert(ua_sess); + if (!ua_sess) { + /* The application has problem or is probably dead. */ + goto error; + } /* Lookup channel in the ust app session */ lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter);