I am developing an R package with compiled Fortran code (rsofun). It successfully compiles and the package builds. However, I get a runtime crash when calling the function that wraps the Fortran code. RStudio raises the following:
R Session Aborted. R encountered a fatal error. The session was terminated.
Unfortunately, this doesn't display the Fortran error that has caused the crash. How can I find the Fortran error message?
To reproduce the crash, run the vignette
vignettes/example_pmodel.Rmd in rsofun
This is odd also because it crashes on one of my machines, but not on the other. On the machine where it crashes, I have (i.a.) the following specified in the Makeconf file:
FC = gfortran -mmacosx-version-min=10.13 FCFLAGS = -Wall -g -O2 $(LTO) FCLIBS_XTRA = FFLAGS = -Wall -g -O2 $(LTO) FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm ALL_FFLAGS = $(PKG_FFLAGS) $(FPICFLAGS) $(SHLIB_FFLAGS) $(FFLAGS) ...
gfortran points to:
lrwxr-xr-x 1 username admin 34 May 14 2020 /usr/local/bin/gfortran -> ../Cellar/gcc/9.3.0_1/bin/gfortran
R version 3.6.3 (2020-02-29) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Catalina 10.15.7 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib locale:  en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
Instead of running an RMarkdown in RStudio, I call the problematic function in a Bash shell with
Rscript (script added to git repo):
... and get the following error:
*** caught segfault *** address 0xa, cause 'memory not mapped' Traceback: 1: run_pmodel_f_bysite(df_drivers$sitename, df_drivers$params_siml[], df_drivers$siteinfo[], df_drivers$forcing[], df_drivers$df_soiltexture[], params_modl = params_modl, makecheck = TRUE) An irrecoverable exception occurred. R is aborting now ... Segmentation fault: 11
Still, I don't know how to fix that. Maybe this issue provides a lead? ("mismatch between currently installed shared libraries and the libraries that were built to install R or packages.").
How can I make sure it's all using the right libraries? I tried to re-install packages (dependencies of the package built here) from source. But no success...