[Rcpp-devel] Passing pointers to objects between libs results in weird UBSAN warning

Dirk Eddelbuettel edd at debian.org
Mon Aug 20 22:47:51 CEST 2018


On 20 August 2018 at 22:16, Jan van der Laan wrote:
| > Instead of using useDynLib in the NAMESPACE, this patch loads the
| > library using library.dynam in .onLoad. In this way, we can take
| > advantage of library.dynam's dots, which are mapped into the
| > subsequent dyn.load call. This call has local=TRUE by default, i.e.,
| > dlopen is called with the RTLD_LOCALattribute. Instead, local=FALSE
| > sets RTLD_GLOBAL, which makes type_info from pkg1 available globally,
| > and thus the RTTI error goes away.

A looooong time ago I had the same issue with package Rmpi because the Open
MPI library used three different shared libraries and, as I recall, one
needed the RTLD_GLOBAL to have visibilty.

Rmpi still does that:

  src/Rmpi.c
  77:    if (!dlopen("libmpi.so.1", RTLD_GLOBAL | RTLD_LAZY) 
  78:     && !dlopen("libmpi.so.0", RTLD_GLOBAL | RTLD_LAZY)
  79:     && !dlopen("libmpi.so", RTLD_GLOBAL | RTLD_LAZY)) {

So as a last resort, you could do something like that. But I don't recommend
setting you your own system for shared libraries etc. That way lies madness.

| OK, this seems to fix it. Not sure if the CRAN people like it when I 
| register my symbols globally as this could bite other packages with the 
| same symbol names. If I understand correctly; I am trying to read in on 
| this stuff :-S
| 
| Tomorrow I will check with lvec and ldat.

These are all cool packages and we should work on making them easily
interoperable. I like how yours build on top of each other.

Thanks also to Iñaki for the very on-target help.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list