Bug 17184 - getDLLRegisteredRoutines: subscript out of bounds
Summary: getDLLRegisteredRoutines: subscript out of bounds
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2016-11-22 19:34 UTC by Matt Dowle
Modified: 2016-11-23 09:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Dowle 2016-11-22 19:34:26 UTC
When two .so objects are loaded with the same name, the warning message constructor in getDLLRegisteredRoutines.character has an out of bounds error.

Using R-release or R-devel on any platform. I assume it occurs with Windows .dll as well but I've only checked with Linux .so.

Pick any package .so you have two of in different paths but the same name. I'll use datatable.so to illustrate as I have that handy but any .so should reproduce.

$ Rdevel
> dyn.load("/home/mdowle/data.table/src/datatable.so")
> length(getDLLRegisteredRoutines("datatable", TRUE))
[1] 4    # correct and ok so far

Now load the same file name in a different place. Does not have to be the same file contents, just the same name.

> dyn.load("/usr/local/lib/R/site-library/data.table/libs/datatable.so")
> getLoadedDLLs()  # shows both loaded ok

> length(getDLLRegisteredRoutines("datatable", TRUE))
Error in dll[["path"]] : subscript out of bounds

In getDLLRegisteredRoutines.character change this line :

 warning(gettextf("multiple DLLs match '%s'. Using '%s'", 
     dll, dll[["path"]]), domain = NA)

to this :

 warning(gettextf("multiple DLLs match '%s'. Using '%s'", 
     names(dll), dlls[[dll]][["path"]]), domain = NA)

Now works correctly :

> length(getDLLRegisteredRoutines("datatable", TRUE))
[1] 4
Warning message:
In getDLLRegisteredRoutines.character("datatable", TRUE) :
  multiple DLLs match 'datatable'. Using '/home/mdowle/data.table/src/datatable.so'
>
Comment 1 Martin Maechler 2016-11-23 09:53:44 UTC
You are right, thank you very much, Matt!

A bug fix hase been committed .. and will be ported to  "R patched", i.e., should be fixed in all future versions of R