[Rd] Consider setting RTLD_GLOBAL when loading packages in LinkingTo
Iñaki Ucar
iuc@r @ending from fedor@project@org
Mon Aug 20 18:36:07 CEST 2018
Hi everyone,
Some of you probably received the following thread from the Rcpp-devel
mailing list:
http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2018-August/010072.html
Summing up, the issue described is the following: pkg1 provides type1
in pkg1.so building on some headers. pkg2 links to pkg1 (BTW,
LinkingTo is actually misleading, because it doesn't really link to
it), i.e., provides type1 in pkg2.so building on the same headers.
Now, pkg2 creates an external pointer to type1 using pkg1.so, and
dynamically casts it and manipulates it using functions in pkg2.so.
This works perfectly, because type1 is exactly the same in pkg1.so and
pkg2.so. *But* UBSAN sanitizers give a runtime error, which arguably
is a false positive. Real example on CRAN:
https://www.stats.ox.ac.uk/pub/bdr/memtests/gcc-UBSAN/ldat/ldat-Ex.Rout
A solution to this would be to dlopen pkg1.so with RTLD_GLOBAL,
instead of RTLD_LOCAL, i.e., dyn.load(local=FALSE). So my proposal is
to automatically set RTLD_GLOBAL for those packages that are listed at
the same time in Depends/Imports/Suggests and LinkingTo, at least for
those machines on CRAN running UBSAN tests.
Regards,
--
Iñaki Ucar
More information about the R-devel
mailing list