R Session Aborted running compiled code

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)
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

And 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

Session Info:

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

[1] 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):

Rscript Rscripts/example_pmodel.R

... and get the following error:

 *** caught segfault ***
address 0xa, cause 'memory not mapped'

 1: run_pmodel_f_bysite(df_drivers$sitename[1], df_drivers$params_siml[[1]],     df_drivers$siteinfo[[1]], df_drivers$forcing[[1]], df_drivers$df_soiltexture[[1]],     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...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.