[Rd] dll symbol loading: possible bug

Dan Davison davison at uchicago.edu
Sun May 1 22:22:53 CEST 2005


Dear R-devel,

I think the following describes a bug in R. It seems to be associated with 
dyn.load() and/or something that happens at start-up. I have not filed a 
bug report yet (because I doubt my ability to rule out other explanations) 
but would happily do so if requested.

Observation:

If two dlls are loaded as a result of dyn.load() calls in .Rprofile, 
subsequent calls to dyn.load() issued at the R prompt result in loss of 
symbol names in the other dll (although not until one tries 
re-dyn.load()ing the second dll; re-dyn.load()ing just one of them works 
OK). This has occurred only since installing R 2.1.0.

Example:

Contents of file dummy1.c:
---------------------------
#include <R.h>
#include <Rdefines.h>
SEXP dummy1() {
     Rprintf("this is dummy1() in C\n") ;
     return R_NilValue ;
}
---------------------------

Contents of file dummy2.c
-------------------------
#include <R.h>
#include <Rdefines.h>

SEXP dummy2() {
     Rprintf("this is dummy2() in C\n") ;
     return R_NilValue ;
}
-------------------------


Files dummy1.so and dummy2.so are present in the directory as a result 
of
system("R CMD SHLIB dummy1.c")
system("R CMD SHLIB dummy2.c")
in a previous R session.


Contents of file .Rprofile:
--------------------
dyn.load("dummy1.so")
dyn.load("dummy2.so")
--------------------

I start R, with this .Rprofile present. Although re-dyn.load()ing of the 
first dll seems unproblematic, re-dyn.load()ing the other dll and all 
subsequent dyn.load()s seem to result in loss of symbols in the other dll:


Type 'q()' to quit R.

> options(STERM='iESS', editor='gnuclient -q')
> ls(all=TRUE)
character(0)
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] TRUE
> dyn.load("dummy1.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] TRUE
> dyn.load("dummy1.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] TRUE
> dyn.load("dummy2.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] FALSE
[1] TRUE
> dyn.load("dummy1.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] FALSE
>


Now there is no .Rprofile. There is no problem:

Type 'q()' to quit R.

> options(STERM='iESS', editor='gnuclient -q')
> ls(all=TRUE)
character(0)
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] FALSE
[1] FALSE
> dyn.load("dummy1.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] FALSE
> dyn.load("dummy2.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] TRUE
> dyn.load("dummy1.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] TRUE
> dyn.load("dummy2.so")
> is.loaded("dummy1") ; is.loaded("dummy2")
[1] TRUE
[1] TRUE
>


The mailing lists contain some reports, for R 2.1.0, mentioning the error 
messages that result, such as

> .Call("dummy1", PACKAGE="dummy1")
Error in .Call("dummy1", PACKAGE = "dummy1") :
 	"C" function name not in DLL for package 'dummy1'

One example is at
http://tolstoy.newcastle.edu.au/R/help/05/04/2928.html

I would be happy to file a proper bug report, if that is deemed 
appropriate. I didn't see anything that was obviously relevant in the news 
file for R 2.1.0. Sorry if I am missing something obvious here.


Thanks very much,

Dan

> version
          _
platform i386-pc-linux-gnu
arch     i386
os       linux-gnu
system   i386, linux-gnu
status
major    2
minor    1.0
year     2005
month    04
day      18
language R
>

Debian "sarge" linux



More information about the R-devel mailing list