Skip to content

Commit da82bcb

Browse files
committed
PSM/PSM2: Disable signal handler hijacking by default
Per discussion on open-mpi/ompi#1767 (and some subsequent phone calls and off-issue email discussions), the PSM library is hijacking signal handlers by default. Specifically: unless the environment variables `IPATH_NO_BACKTRACE=1` (for PSM / Intel TrueScale) is set, the library constructor for this library will hijack various signal handlers for the purpose of invoking its own error reporting mechanisms. This may be a bit *surprising*, but is not a *problem*, per se. The real problem is that older versions of at least the PSM library do not unregister these signal handlers upon being unloaded from memory. Hence, a segv can actually result in a double segv (i.e., the original segv and then another segv when the now-non-existent signal handler is invoked). This PSM signal hijacking subverts Open MPI's own signal reporting mechanism, which may be a bit surprising for some users (particularly those who do not have Intel TrueScale). As such, we disable it by default so that Open MPI's own error-reporting mechanisms are used. Additionally, there is a typo in the library destructor for the PSM2 library that may cause problems in the unloading of its signal handlers. This problem can be avoided by setting `HFI_NO_BACKTRACE=1` (for PSM2 / Intel OmniPath). This is further compounded by the fact that the PSM / PSM2 libraries can be loaded by the OFI MTL and the usNIC BTL (because they are loaded by libfabric), even when there is no Intel networking hardware present. Having the PSM/PSM2 libraries behave this way when no Intel hardware is present is clearly undesirable (and is likely to be fixed in future releases of the PSM/PSM2 libraries). This commit sets the following two environment variables to disable this behavior from the PSM/PSM2 libraries (if they are not already set): * IPATH_NO_BACKTRACE=1 * HFI_NO_BACKTRACE=1 If the user has set these variables before invoking Open MPI, we will not override their values (i.e., their preferences will be honored). Signed-off-by: Jeff Squyres <[email protected]> (cherry picked from commit open-mpi/ompi@5071602)
1 parent 27f48de commit da82bcb

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

ompi/mpi/java/c/mpi_MPI.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* All rights reserved.
1313
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1414
* reserved.
15-
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
15+
* Copyright (c) 2015-2016 Cisco Systems, Inc. All rights reserved.
1616
* Copyright (c) 2015 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
@@ -135,6 +135,10 @@ OBJ_CLASS_INSTANCE(ompi_java_buffer_t,
135135
*/
136136
jint JNI_OnLoad(JavaVM *vm, void *reserved)
137137
{
138+
// Ensure that PSM signal hijacking is disabled *before* loading
139+
// the library (see comment in the function for more detail).
140+
opal_init_psm();
141+
138142
libmpi = dlopen("libmpi." OPAL_DYN_LIB_SUFFIX, RTLD_NOW | RTLD_GLOBAL);
139143

140144
#if defined(HAVE_DL_INFO) && defined(HAVE_LIBGEN_H)

opal/runtime/opal.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
* Copyright (c) 2004-2007 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
9-
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
14-
* Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2010-2016 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2014 Intel, Inc. All rights reserved.
1718
* $COPYRIGHT$
18-
*
19+
*
1920
* Additional copyrights may follow
20-
*
21+
*
2122
* $HEADER$
2223
*/
2324

@@ -53,7 +54,7 @@ OPAL_DECLSPEC extern int opal_cache_line_size;
5354
OPAL_DECLSPEC int opal_init(int* pargc, char*** pargv);
5455

5556
/**
56-
* Finalize the OPAL layer, including the MCA system.
57+
* Finalize the OPAL layer, including the MCA system.
5758
*
5859
* @retval OPAL_SUCCESS Upon success.
5960
* @retval OPAL_ERROR Upon failure.
@@ -75,7 +76,14 @@ OPAL_DECLSPEC int opal_finalize(void);
7576
OPAL_DECLSPEC int opal_init_util(int* pargc, char*** pargv);
7677

7778
/**
78-
* Finalize the OPAL layer, excluding the MCA system.
79+
* Disable PSM/PSM2 signal hijacking.
80+
*
81+
* See comment in the function for more detail.
82+
*/
83+
OPAL_DECLSPEC int opal_init_psm(void);
84+
85+
/**
86+
* Finalize the OPAL layer, excluding the MCA system.
7987
*
8088
* @retval OPAL_SUCCESS Upon success.
8189
* @retval OPAL_ERROR Upon failure.

opal/runtime/opal_init.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2007-2016 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
1515
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
1616
* Copyright (c) 2010-2013 Los Alamos National Security, LLC.
@@ -246,6 +246,34 @@ opal_err2str(int errnum, const char **errmsg)
246246
}
247247

248248

249+
int opal_init_psm(void)
250+
{
251+
/* Very early in the init sequence -- before *ANY* MCA components
252+
are opened -- we need to disable some behavior from the PSM and
253+
PSM2 libraries (by default): at least some old versions of
254+
these libraries hijack signal handlers during their library
255+
constructors and then do not un-hijack them when the libraries
256+
are unloaded.
257+
258+
It is a bit of an abstraction break that we have to put
259+
vendor/transport-specific code in the OPAL core, but we're
260+
out of options, unfortunately.
261+
262+
NOTE: We only disable this behavior if the corresponding
263+
environment variables are not already set (i.e., if the
264+
user/environment has indicated a preference for this behavior,
265+
we won't override it). */
266+
if (NULL == getenv("IPATH_NO_BACKTRACE")) {
267+
opal_setenv("IPATH_NO_BACKTRACE", "1", true, &environ);
268+
}
269+
if (NULL == getenv("HFI_NO_BACKTRACE")) {
270+
opal_setenv("HFI_NO_BACKTRACE", "1", true, &environ);
271+
}
272+
273+
return OPAL_SUCCESS;
274+
}
275+
276+
249277
int
250278
opal_init_util(int* pargc, char*** pargv)
251279
{
@@ -301,6 +329,10 @@ opal_init_util(int* pargc, char*** pargv)
301329
goto return_error;
302330
}
303331

332+
// Disable PSM signal hijacking (see comment in function for more
333+
// details)
334+
opal_init_psm();
335+
304336
/* Setup the parameter system */
305337
if (OPAL_SUCCESS != (ret = mca_base_param_init())) {
306338
error = "mca_base_param_init";

0 commit comments

Comments
 (0)