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