Skip to content

Commit 58d2366

Browse files
committed
PSM/PSM2: Disable signal handler hijacking by default
Per discussion on open-mpi#1767 (and some subsequent phone calls and off-issue email discussions), the PSM and PSM2 libraries are hijacking signal handlers by default. Specifically: unless the environment variables `IPATH_NO_BACKTRACE=1` (for PSM / Intel TrueScale) and `HFI_NO_BACKTRACE=1` (for PSM2 / Intel OmniPath) are set, the library constructors for these two libraries will hijack various signal handlers for the purpose of invoking their 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 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 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). Finally, this 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/OmniPath hardware). As such, we disable it by default so that Open MPI's own error-reporting mechanisms are used. This commit will set the following two environment variables to disable the signal hijacking 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]>
1 parent eb37574 commit 58d2366

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
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.
@@ -131,6 +131,10 @@ OBJ_CLASS_INSTANCE(ompi_java_buffer_t,
131131
*/
132132
jint JNI_OnLoad(JavaVM *vm, void *reserved)
133133
{
134+
// Ensure that PSM signal hijacking is disabled *before* loading
135+
// the library (see comment in the function for more detail).
136+
opal_init_psm();
137+
134138
libmpi = dlopen("libmpi." OPAL_DYN_LIB_SUFFIX, RTLD_NOW | RTLD_GLOBAL);
135139

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

opal/runtime/opal.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
13-
* Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2010-2016 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2014 Intel, Inc. All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -76,6 +76,13 @@ OPAL_DECLSPEC int opal_finalize(void);
7676
*/
7777
OPAL_DECLSPEC int opal_init_util(int* pargc, char*** pargv);
7878

79+
/**
80+
* Disable PSM/PSM2 signal hijacking.
81+
*
82+
* See comment in the function for more detail.
83+
*/
84+
OPAL_DECLSPEC int opal_init_psm(void);
85+
7986
/**
8087
* Finalize the OPAL layer, excluding the MCA system.
8188
*

opal/runtime/opal_init.c

Lines changed: 30 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-2015 Los Alamos National Security, LLC.
@@ -265,6 +265,31 @@ opal_err2str(int errnum, const char **errmsg)
265265
}
266266

267267

268+
int opal_init_psm(void)
269+
{
270+
/* Very early in the init sequence -- before *ANY* MCA components
271+
are opened -- we need to disable bad behavior from the PSM and
272+
PSM2 libraries: at least some old versions of these libraries
273+
hijack signal handlers during their library constructors and
274+
then do not un-hijack them when the libraries are unloaded.
275+
276+
It is a bit of an abstraction break that we have to put
277+
vendor/transport-specific code in the OPAL core, but we're
278+
out of options, unfortunately.
279+
280+
NOTE: We only disable this behavior if the corresponding
281+
environment variables are not already set (i.e., if the
282+
user/environment has indicated a preference for this behavior,
283+
we won't override it). */
284+
if (NULL == getenv("IPATH_NO_BACKTRACE")) {
285+
opal_setenv("IPATH_NO_BACKTRACE", "1", true, &environ);
286+
}
287+
if (NULL == getenv("HFI_NO_BACKTRACE")) {
288+
opal_setenv("HFI_NO_BACKTRACE", "1", true, &environ);
289+
}
290+
}
291+
292+
268293
int
269294
opal_init_util(int* pargc, char*** pargv)
270295
{
@@ -328,6 +353,10 @@ opal_init_util(int* pargc, char*** pargv)
328353
goto return_error;
329354
}
330355

356+
// Disable PSM signal hijacking (see comment in function for more
357+
// details)
358+
opal_init_psm();
359+
331360
/* Setup the parameter system */
332361
if (OPAL_SUCCESS != (ret = mca_base_var_init())) {
333362
error = "mca_base_var_init";

0 commit comments

Comments
 (0)