From c4d5de9d68e5fde4c5ef30f88f2b8aa5751ea031 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 9 Jun 2016 16:14:28 -0400 Subject: [PATCH] Fix: leak of UST app hash tables MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The ht_cleanup thread is shut down before the queue of rcu callbacks is emptied by the rcu_barrier(). Since callbacks added by call_rcu can push hash tables through the ht_cleanup pipe, we run into cases where the clean-up thread has been shutdown and hash tables pushed through the clean-up pipe are leaked. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a72d44a3e..ee19ef840 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -6226,6 +6226,13 @@ exit_init_data: rcu_thread_offline(); rcu_unregister_thread(); + /* + * Ensure all prior call_rcu are done. call_rcu callbacks may push + * hash tables to the ht_cleanup thread. Therefore, we ensure that + * the queue is empty before shutting down the clean-up thread. + */ + rcu_barrier(); + ret = notify_thread_pipe(ht_cleanup_quit_pipe[1]); if (ret < 0) { ERR("write error on ht_cleanup quit pipe"); @@ -6255,9 +6262,6 @@ exit_health_sessiond_cleanup: exit_create_run_as_worker_cleanup: exit_options: - /* Ensure all prior call_rcu are done. */ - rcu_barrier(); - sessiond_cleanup_options(); exit_set_signal_handler: -- 2.34.1