summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2020-02-19 12:24:15 +0100
committerXavi Hernandez <xhernandez@redhat.com>2020-02-19 12:30:43 +0100
commit672a53d3d30d6932e25d81f64c7fecbdb97d15c4 (patch)
tree43c2d3b6ee749a582d536bda23554e332e47315e /libglusterfs
parentb1a18ef5d0ad7317f4c22cd9c765c63634100906 (diff)
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. Change-Id: Id7cfb4407fcf208e28f03a7c3cdc3ef9c1f3bf9b Fixes: bz#1801684 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/mem-pool.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index d77be55db5a..ea37ffa5015 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -550,25 +550,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