Skip to content

Commit 1cdf2f1

Browse files
authored
Merge pull request #565 from JuliaParallel/vc/oh_openmpi
openmpi needs to be opened with RTLD_GLOBAL
2 parents 51657da + d8fad5e commit 1cdf2f1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/MPIPreferences/src/MPIPreferences.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,21 @@ function identify_abi(libmpi)
143143
# implementations.
144144
buf = Array{UInt8}(undef, 8192)
145145
buflen = Ref{Cint}()
146-
dlopen(libmpi) do hdl
147-
ptr = dlsym(hdl, :MPI_Get_library_version)
146+
147+
@static if Sys.isunix()
148+
# need to open libmpi with RTLD_GLOBAL flag for Linux, before
149+
# any ccall cannot use RTLD_DEEPBIND; this leads to segfaults
150+
# at least on Ubuntu 15.10
151+
hndl = Libdl.dlopen(libmpi, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL)
152+
else
153+
hndl = Libdl.dlopen(libmpi)
154+
end
155+
156+
try
157+
ptr = dlsym(hndl, :MPI_Get_library_version)
148158
ccall(ptr, Cint, (Ptr{UInt8}, Ref{Cint}), buf, buflen)
159+
finally
160+
Libdl.dlclose(hndl)
149161
end
150162

151163
@assert buflen[] < 8192

0 commit comments

Comments
 (0)