From 78b21c924d8b5c8d4422445b1c0ce32223ba112d Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Tue, 17 Sep 2019 14:45:51 -0400 Subject: [PATCH 1/2] Conform MPIR_Breakpoint to MPIR standard. - Fix MPIR_Breakpoint standard violation by returning void instead of a void*. Signed-off-by: Austen Lauria (cherry picked from commit 067adfa417f95396c713f6e6597619fac94f0048) --- orte/orted/orted_submit.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/orte/orted/orted_submit.c b/orte/orted/orted_submit.c index 9b7af946ab3..d0f8097ccac 100644 --- a/orte/orted/orted_submit.c +++ b/orte/orted/orted_submit.c @@ -173,7 +173,7 @@ char MPIR_attach_fifo[MPIR_MAX_PATH_LENGTH] = {0}; int MPIR_force_to_main = 0; static void orte_debugger_init_before_spawn(orte_job_t *jdata); -ORTE_DECLSPEC void* __opal_attribute_optnone__ MPIR_Breakpoint(void); +ORTE_DECLSPEC void __opal_attribute_optnone__ MPIR_Breakpoint(void); /* * Attempt to prevent the compiler from optimizing out @@ -191,14 +191,26 @@ ORTE_DECLSPEC void* __opal_attribute_optnone__ MPIR_Breakpoint(void); * See the following git issue for more discussion: * https://github.com/open-mpi/ompi/issues/5501 */ -static volatile void* volatile noop_mpir_breakpoint_ptr = NULL; +volatile void* volatile noop_mpir_breakpoint_ptr = NULL; /* * Breakpoint function for parallel debuggers */ -void* MPIR_Breakpoint(void) +void MPIR_Breakpoint(void) { - return noop_mpir_breakpoint_ptr; + /* + * Actually do something with this pointer to make + * sure the compiler does not optimize out this function. + * The compiler should be forced to keep this + * function around due to the volatile void* type. + * + * This pointer doesn't actually do anything other than + * prevent unwanted optimization, and + * *should not* be used anywhere else in the code. + * So pointing this to the weeds should be OK. + */ + noop_mpir_breakpoint_ptr = (volatile void *) 0x42; + return; } /* local objects */ From 85ffb47c9a293e9fd1e2c9c4bbc1707df5d59530 Mon Sep 17 00:00:00 2001 From: Austen Lauria Date: Wed, 18 Sep 2019 17:44:40 -0400 Subject: [PATCH 2/2] Add 'orte_' prefix to noop_mpir_breakpoint_ptr. Signed-off-by: Austen Lauria (cherry picked from commit 77144689f062f38d2edc9086e3fbb99c3d855f9a) --- orte/orted/orted_submit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orte/orted/orted_submit.c b/orte/orted/orted_submit.c index d0f8097ccac..6b956cf4087 100644 --- a/orte/orted/orted_submit.c +++ b/orte/orted/orted_submit.c @@ -191,7 +191,7 @@ ORTE_DECLSPEC void __opal_attribute_optnone__ MPIR_Breakpoint(void); * See the following git issue for more discussion: * https://github.com/open-mpi/ompi/issues/5501 */ -volatile void* volatile noop_mpir_breakpoint_ptr = NULL; +volatile void* volatile orte_noop_mpir_breakpoint_ptr = NULL; /* * Breakpoint function for parallel debuggers @@ -209,7 +209,7 @@ void MPIR_Breakpoint(void) * *should not* be used anywhere else in the code. * So pointing this to the weeds should be OK. */ - noop_mpir_breakpoint_ptr = (volatile void *) 0x42; + orte_noop_mpir_breakpoint_ptr = (volatile void *) 0x42; return; }