[Rd] Should R Packages Unload Dynamic Libraries When They Unload?

2014-11-11 Thread brodie gaslam


From Hadley's C best practices 
(http://r-pkgs.had.co.nz/src.html#c-best-practices):

> Like with C++, whenever you use C code in your package, you should unload the 
> DLL when the package is unloaded:

.onUnload <- function (libpath) {
  library.dynam.unload("mypackage", libpath)
}

Writing R Extensions on the other hand doesn't even mention this (AFAIK). I can 
see how it would be polite to unload the dlls, but doing so seems to cause some 
weird problems for me with packages that are loaded/unloaded/reloaded. 
Additionally, there are some mentions that suggest maybe unloading isn't 
required. From ?library.dynam:

> Note that whether or not it is possible to unload a DLL and then reload a 
> revised version of the same file is OS-dependent: see the ‘Value’ section of 
> the help for dyn.unload.

though this shouldn't affect objects that are not modified. Then there is this 
comment from Brian Ripley in R-devel 
(https://stat.ethz.ch/pipermail/r-devel/2010-November/059062.html):

> Having said all that, my experience is that unloading the DLL often does not 
> help if you need to load it again (and that is why e.g. tcltk does not unload 
> its DLL).

Is it acceptable for packages to leave the C libraries loaded when they are 
unloaded?


I'm on R 3.1.1 on a Mac OS X, though this question is not specific to my system.


I originally asked this on SO 
(http://stackoverflow.com/questions/26691878/must-r-packages-unload-dynamic-libraries-when-they-unload),
 but got crickets.
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] segfault with readDCF on R 3.1.2 on AIX 6.1 when using install.packages

2014-11-11 Thread Vinh Nguyen
Dear list (re-posting from r-help as r-devel is probably more appropriate),

I was able to successfully compile R on our AIX box at work using the
GNU compilers following the instructions on the R Administration
guide.  The output can be seen at here
(https://gist.github.com/nguyenvinh/504321ea9c89d8919bef) and yields
no errors .

However, I get a segfault whenever I try to use the install.packages
function to install packages.  Using debug, I was able to trace it to
the readDCF function:

Browse[2]>
debug: if (!all) return(.Internal(readDCF(file, fields, keep.white)))
Browse[2]>
debug: return(.Internal(readDCF(file, fields, keep.white)))
Browse[2]>

 *** caught segfault ***
address 4, cause 'invalid permissions'

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Was curious if anyone has a clue on why such error exists or what I
could do to fix it?  I'm able to install packages via R CMD INSTALL,
but I would hate to have to manually determine dependencies, download
the source for each package, and install them "by hand" via R CMD
INSTALL.

I went back and compiled older versions of R to see if this error
exists.  On R 3.0.3, I get:

debug(available.packages)
install.packages('ggplot2', dep=TRUE, repo='http://cran.stat.ucla.edu')
...
Browse[2]>
debug: z <- res0 <- tryCatch(read.dcf(file = tmpf), error = identity)
Browse[2]>
Error: segfault from C stack overflow

On R 2.15.3, I do not see the error.

Would be great to get this resolved.  Thank you for your help.

-- Vinh

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel