From 952d01db70eab4cbe11ff4557434acaa928685a4 Mon Sep 17 00:00:00 2001 From: Rolf vandeVaart Date: Wed, 7 Oct 2015 12:56:58 -0400 Subject: [PATCH] Add volatile to workaround GCC optimization bug in 4.9.2 and greater. Thanks to oere for fix --- opal/mca/memory/linux/memory_linux.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/opal/mca/memory/linux/memory_linux.h b/opal/mca/memory/linux/memory_linux.h index bfc00bf6dbb..24cb303c1f8 100644 --- a/opal/mca/memory/linux/memory_linux.h +++ b/opal/mca/memory/linux/memory_linux.h @@ -32,12 +32,20 @@ typedef struct opal_memory_linux_component_t { #endif #if MEMORY_LINUX_PTMALLOC2 - /* Ptmalloc2-specific data */ - bool free_invoked; - bool malloc_invoked; - bool realloc_invoked; - bool memalign_invoked; - bool munmap_invoked; + /* Ptmalloc2-specific data. Note that these variables are all marked as volatile. + * This is needed because of what may be a buggy optimization in the GCC 4.9.2 + * compilers and later. These variables are used in different code paths which the + * compiler is not aware of. + * Extra details located at these URLs: + * Open MPI User List: http://www.open-mpi.org/community/lists/users/2015/06/27039.php + * Bug Discussion: https://github.com/open-mpi/ompi/pull/625 + * GCC Discussion: https://gcc.gnu.org/ml/gcc-bugs/2015-06/msg00757.html + */ + volatile bool free_invoked; + volatile bool malloc_invoked; + volatile bool realloc_invoked; + volatile bool memalign_invoked; + volatile bool munmap_invoked; #endif } opal_memory_linux_component_t;