Bug 16446 - Unloading dynamic library bug
Summary: Unloading dynamic library bug
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.2.1
Hardware: All All
: P5 major
Assignee: R-core
Depends on:
Reported: 2015-06-23 16:47 UTC by talhayon1
Modified: 2015-07-04 18:39 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description talhayon1 2015-06-23 16:47:21 UTC
The R_callDLLUnload function removes a Dllinfo from the LoadedInfo array by releasing its allocated memory and moving the following items one item backwards.

However there is additional reference to that array kept in a 'DLLs' object inside the package namespace (put there by loadNamespace). That pointer is not updated and is still pointing to the same place, meaning that every dynamic library loaded after an unloaded library has a wrong pointer. That pointer is used by the getCallingDLLe inside .Call.

This can be reproduced by loading two dlls, unloading the first and calling .Call for some function in the second dll (without the PACKAGE argument).

This will tell you it cannot resolve the function name.

I solved it internally by adding another level of dereferencing in the LoadedDLL array but it might need a better solution.
Comment 1 talhayon1 2015-07-04 18:39:19 UTC
I neglected to mention that this causes occasional bus error crashes with a "non-existent physical address" message.