From a41e9446f81f5f2bedfafb1264f55e28276376ff 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 bd021b819fc..ef5a20ab42c 100644 --- a/orte/orted/orted_submit.c +++ b/orte/orted/orted_submit.c @@ -172,7 +172,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 @@ -190,14 +190,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 71c4c194e09c6c36ff7a769f1f1aed760ec7621f 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 ef5a20ab42c..9b1c2e9e6ae 100644 --- a/orte/orted/orted_submit.c +++ b/orte/orted/orted_submit.c @@ -190,7 +190,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 @@ -208,7 +208,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; }