Skip to content

Commit dd540a8

Browse files
committed
openmpi needs to be opened with RTLD_GLOBAL
1 parent 2080aed commit dd540a8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/MPIPreferences/src/MPIPreferences.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,21 @@ function identify_abi(libmpi)
8282
# implementations.
8383
buf = Array{UInt8}(undef, 8192)
8484
buflen = Ref{Cint}()
85-
dlopen(libmpi) do hdl
85+
86+
@static if Sys.isunix()
87+
# need to open libmpi with RTLD_GLOBAL flag for Linux, before
88+
# any ccall cannot use RTLD_DEEPBIND; this leads to segfaults
89+
# at least on Ubuntu 15.10
90+
hndl = Libdl.dlopen(libmpi, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL)
91+
else
92+
hndl = Libdl.dlopen(libmpi)
93+
end
94+
95+
try
8696
ptr = dlsym(hdl, :MPI_Get_library_version)
8797
ccall(ptr, Cint, (Ptr{UInt8}, Ref{Cint}), buf, buflen)
98+
finally
99+
Libdl.dlclose(hndl)
88100
end
89101

90102
@assert buflen[] < 8192

0 commit comments

Comments
 (0)