|
|
9f5ccc |
From 10f1730073b9fb02d2ed7f7de855afd6df0e5202 Mon Sep 17 00:00:00 2001
|
|
|
9f5ccc |
From: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
9f5ccc |
Date: Wed, 19 Feb 2020 12:24:15 +0100
|
|
|
9f5ccc |
Subject: [PATCH 355/355] core: Prevent crash on process termination
|
|
|
9f5ccc |
|
|
|
9f5ccc |
A previous patch (ce61da816a) has fixed a use-after-free issue,
|
|
|
9f5ccc |
but it doesn't work well when the final cleanup is done at process
|
|
|
9f5ccc |
termination because gluster doesn't stop other threads before
|
|
|
9f5ccc |
calling exit().
|
|
|
9f5ccc |
|
|
|
9f5ccc |
For this reason, the final cleanup is removed to avoid the crash,
|
|
|
9f5ccc |
at least until the termination sequence properly stops all gluster
|
|
|
9f5ccc |
threads before exiting the program.
|
|
|
9f5ccc |
|
|
|
9f5ccc |
Upstream patch:
|
|
|
9f5ccc |
> Upstream patch link: https://review.gluster.org/c/glusterfs/+/24138
|
|
|
9f5ccc |
> Change-Id: Id7cfb4407fcf208e28f03a7c3cdc3ef9c1f3bf9b
|
|
|
9f5ccc |
> Fixes: bz#1801684
|
|
|
9f5ccc |
> Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
9f5ccc |
|
|
|
9f5ccc |
Change-Id: Id7cfb4407fcf208e28f03a7c3cdc3ef9c1f3bf9b
|
|
|
9f5ccc |
BUG: 1800703
|
|
|
9f5ccc |
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
9f5ccc |
Reviewed-on: https://code.engineering.redhat.com/gerrit/192344
|
|
|
9f5ccc |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
9f5ccc |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
9f5ccc |
---
|
|
|
9f5ccc |
libglusterfs/src/mem-pool.c | 30 +++++++++++-------------------
|
|
|
9f5ccc |
1 file changed, 11 insertions(+), 19 deletions(-)
|
|
|
9f5ccc |
|
|
|
9f5ccc |
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
|
|
|
9f5ccc |
index 2b41c01..73503e0 100644
|
|
|
9f5ccc |
--- a/libglusterfs/src/mem-pool.c
|
|
|
9f5ccc |
+++ b/libglusterfs/src/mem-pool.c
|
|
|
9f5ccc |
@@ -541,25 +541,17 @@ mem_pools_preinit(void)
|
|
|
9f5ccc |
static __attribute__((destructor)) void
|
|
|
9f5ccc |
mem_pools_postfini(void)
|
|
|
9f5ccc |
{
|
|
|
9f5ccc |
- per_thread_pool_list_t *pool_list, *next;
|
|
|
9f5ccc |
-
|
|
|
9f5ccc |
- /* This is part of a process shutdown (or dlclose()) which means that
|
|
|
9f5ccc |
- * most probably all threads should be stopped. However this is not the
|
|
|
9f5ccc |
- * case for gluster and there are even legitimate situations in which we
|
|
|
9f5ccc |
- * could have some threads alive. What is sure is that none of those
|
|
|
9f5ccc |
- * threads should be using anything from this library, so destroying
|
|
|
9f5ccc |
- * everything here should be fine and safe. */
|
|
|
9f5ccc |
-
|
|
|
9f5ccc |
- list_for_each_entry_safe(pool_list, next, &pool_threads, thr_list)
|
|
|
9f5ccc |
- {
|
|
|
9f5ccc |
- mem_pool_thread_destructor(pool_list);
|
|
|
9f5ccc |
- }
|
|
|
9f5ccc |
-
|
|
|
9f5ccc |
- list_for_each_entry_safe(pool_list, next, &pool_free_threads, thr_list)
|
|
|
9f5ccc |
- {
|
|
|
9f5ccc |
- list_del(&pool_list->thr_list);
|
|
|
9f5ccc |
- FREE(pool_list);
|
|
|
9f5ccc |
- }
|
|
|
9f5ccc |
+ /* TODO: This function should destroy all per thread memory pools that
|
|
|
9f5ccc |
+ * are still alive, but this is not possible right now because glibc
|
|
|
9f5ccc |
+ * starts calling destructors as soon as exit() is called, and
|
|
|
9f5ccc |
+ * gluster doesn't ensure that all threads have been stopped before
|
|
|
9f5ccc |
+ * calling exit(). Existing threads would crash when they try to use
|
|
|
9f5ccc |
+ * memory or they terminate if we destroy things here.
|
|
|
9f5ccc |
+ *
|
|
|
9f5ccc |
+ * When we propertly terminate all threads, we can add the needed
|
|
|
9f5ccc |
+ * code here. Till then we need to leave the memory allocated. Most
|
|
|
9f5ccc |
+ * probably this function will be executed on process termination,
|
|
|
9f5ccc |
+ * so the memory will be released anyway by the system. */
|
|
|
9f5ccc |
}
|
|
|
9f5ccc |
|
|
|
9f5ccc |
/* Call mem_pools_init() once threading has been configured completely. This
|
|
|
9f5ccc |
--
|
|
|
9f5ccc |
1.8.3.1
|
|
|
9f5ccc |
|