Skip to content

Commit 17b9b77

Browse files
committed
Merge pull request open-mpi#653 from rolfv/pr/add-volatile-where-needed-2.x
Add volatile to workaround GCC optimization bug in 4.9.2 and greater.
2 parents 3471567 + e683f5f commit 17b9b77

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

opal/mca/memory/linux/memory_linux.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ typedef struct opal_memory_linux_component_t {
3232
#endif
3333

3434
#if MEMORY_LINUX_PTMALLOC2
35-
/* Ptmalloc2-specific data */
36-
bool free_invoked;
37-
bool malloc_invoked;
38-
bool realloc_invoked;
39-
bool memalign_invoked;
40-
bool munmap_invoked;
35+
/* Ptmalloc2-specific data. Note that these variables are all marked as volatile.
36+
* This is needed because of what may be a buggy optimization in the GCC 4.9.2
37+
* compilers and later. These variables are used in different code paths which the
38+
* compiler is not aware of.
39+
* Extra details located at these URLs:
40+
* Open MPI User List: http://www.open-mpi.org/community/lists/users/2015/06/27039.php
41+
* Bug Discussion: https://github.com/open-mpi/ompi/pull/625
42+
* GCC Discussion: https://gcc.gnu.org/ml/gcc-bugs/2015-06/msg00757.html
43+
*/
44+
volatile bool free_invoked;
45+
volatile bool malloc_invoked;
46+
volatile bool realloc_invoked;
47+
volatile bool memalign_invoked;
48+
volatile bool munmap_invoked;
4149
#endif
4250
} opal_memory_linux_component_t;
4351

0 commit comments

Comments
 (0)