Bug 16796 - dyn.load option for RTLD_DEEPBIND
Summary: dyn.load option for RTLD_DEEPBIND
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R-devel (trunk)
Hardware: x86_64/x64/amd64 (64-bit) Linux-RHEL
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2016-04-04 18:18 UTC by Michael Schubmehl
Modified: 2016-04-04 18:19 UTC (History)
0 users

See Also:


Attachments
patch to enable dyn.load(deep=TRUE) (8.27 KB, patch)
2016-04-04 18:18 UTC, Michael Schubmehl
Details | Diff
dot.c MKL-based test case (1.30 KB, text/plain)
2016-04-04 18:19 UTC, Michael Schubmehl
Details
dot_nomkl.c non-MKL test case (1.03 KB, text/plain)
2016-04-04 18:19 UTC, Michael Schubmehl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schubmehl 2016-04-04 18:18:52 UTC
Created attachment 2052 [details]
patch to enable dyn.load(deep=TRUE)

The dyn.load call to dlopen does not support the RTLD_DEEPBIND flag, which specifies that a shared object should check its own symbols before resolving against the global symbol table. Letting users set this flag would allow, for example, a shared object linked statically against the ILP64 interface of MKL BLAS to be used with R built against LP64 MKL BLAS to compute the dot product of two long vectors. Without this change, the cblas_ddot call resolves to the LP64 symbol already loaded by R, and does not work correctly. (I was not able to compile R with ILP64, which I believe is expected.)

The attached patch implements and documents a "deep" argument to dyn.load to enable this behavior. The tests run under "make check" appear to work with this patch on my RHEL7.2 Linux box. I made the corresponding changes for Windows, but don't have a compiler handy to test.

The first test case (dot.c) is a real-life MKL example, and the second test case (dot_nomkl.c) is a more contrived example of a name collision between a shared object and the default libRblas (but does not require MKL to reproduce). Instructions for compiling and testing are included in the attachments as comments.

Thanks!
Comment 1 Michael Schubmehl 2016-04-04 18:19:27 UTC
Created attachment 2053 [details]
dot.c MKL-based test case
Comment 2 Michael Schubmehl 2016-04-04 18:19:51 UTC
Created attachment 2054 [details]
dot_nomkl.c non-MKL test case