LoadLibrary failure: Invalid access to memory location


#1

I am wondering what to do to resolve the following error message:
Error in inDL(x, as.logical(local), as.logical(now), …) :
unable to load shared object ‘C:/Users/VH6B79~1/AppData/Local/Temp/Rtmpui6NFO/file206476487e95.dll’:
LoadLibrary failure: Invalid access to memory location.

This folder location is not actually inaccessible, as R and RStan have no problem writing dozens of other files here in the same session. But it always seems to get hung up on a DLL file at some point. Any ideas for resolving it? It would be much appreciated.

Operating System: Windows 7 Enterprise (64-Bit)
Interface Version: RStan 2.17.3
Output of writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”))):
CXXFLAGS=-O3 -Wno-unused-variable -Wno-unused-function

CXXFLAGS += -flto -Wno-deprecated-declarations

Output of devtools::session_info("rstan”):
Session info ------------------------------------------------------------------------------------------------------------
setting value
version R version 3.4.2 (2017-09-28)
system x86_64, mingw32
ui RStudio (1.1.442)
language (EN)
collate English_United States.1252
tz America/Los_Angeles
date 2018-03-28

Packages ----------------------------------------------------------------------------------------------------------------
package * version date source
assertthat 0.2.0 2017-04-11 CRAN (R 3.4.4)
BH 1.66.0-1 2018-02-13 CRAN (R 3.4.3)
cli 1.0.0 2017-11-05 CRAN (R 3.4.4)
colorspace 1.3-2 2016-12-14 CRAN (R 3.4.2)
crayon 1.3.4 2017-09-16 CRAN (R 3.4.4)
dichromat 2.0-0 2013-01-24 CRAN (R 3.4.1)
digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.4.2)
glue 1.2.0 2017-10-29 CRAN (R 3.4.4)
graphics * 3.4.2 2017-09-28 local
grDevices * 3.4.2 2017-09-28 local
grid 3.4.2 2017-09-28 local
gridExtra 2.3 2017-09-09 CRAN (R 3.4.2)
gtable 0.2.0 2016-02-26 CRAN (R 3.4.2)
inline 0.3.14 2015-04-13 CRAN (R 3.4.4)
labeling 0.3 2014-08-23 CRAN (R 3.4.1)
lattice 0.20-35 2017-03-25 CRAN (R 3.4.2)
lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.2)
magrittr 1.5 2014-11-22 CRAN (R 3.4.2)
MASS 7.3-49 2018-02-23 CRAN (R 3.4.4)
Matrix 1.2-12 2017-11-16 CRAN (R 3.4.4)
methods * 3.4.2 2017-09-28 local
munsell 0.4.3 2016-02-13 CRAN (R 3.4.2)
pillar 1.2.1 2018-02-27 CRAN (R 3.4.4)
plyr 1.8.4 2016-06-08 CRAN (R 3.4.2)
R6 2.2.2 2017-06-17 CRAN (R 3.4.2)
RColorBrewer 1.1-2 2014-12-07 CRAN (R 3.4.1)
Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4)
RcppEigen 0.3.3.4.0 2018-02-07 CRAN (R 3.4.4)
reshape2 1.4.3 2017-12-11 CRAN (R 3.4.4)
rlang 0.2.0 2018-02-20 CRAN (R 3.4.4)
rstan * 2.17.3 2018-01-20 CRAN (R 3.4.4)
scales 0.5.0 2017-08-24 CRAN (R 3.4.2)
StanHeaders * 2.17.2 2018-01-20 CRAN (R 3.4.4)
stats * 3.4.2 2017-09-28 local
stats4 3.4.2 2017-09-28 local
stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
stringr 1.3.0 2018-02-19 CRAN (R 3.4.4)
tibble 1.4.2 2018-01-22 CRAN (R 3.4.4)
tools 3.4.2 2017-09-28 local
utf8 1.1.3 2018-01-03 CRAN (R 3.4.4)
utils * 3.4.2 2017-09-28 local
viridisLite 0.3.0 2018-02-01 CRAN (R 3.4.4)


#2

It sounds like some security / permission setting thing or maybe an anti-virus policy that prevents R from dynamically loading the DLL. You shouldn’t have -flto in CXXFLAGS but I doubt that will make any difference.


#3

Actually, for whatever reason, I deleted that flag and now the stan script runs without throwing the error! Thank you!