"*** caught segfault ***" when running the same program multiple times


#1

I run the same RStan program multiple times and it ends up killing R. Any ideas? I have all the relevant info below.

Error message from R (run in my terminal):

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

Traceback:
 1: .Call(list(name = "CppObject__finalize", address = <pointer: 0x7ff5d8c36870>,     dll = list(name = "Rcpp", path = "/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/libs/Rcpp.so",         dynamicLookup = TRUE, handle = <pointer: 0x7ff5d8d0f690>,         info = <pointer: 0x7ff5d9056040>), numParameters = 2L),     <pointer: 0x7ff5d8c98bb0>, .pointer)
 2: x$.self$finalize()
 3: (function (x) x$.self$finalize())(<environment>)

I’m trying to get a simple, reproducible example going, but this is happening with a more complex model. It happens consistently, but not with a very simple Stan program.

Any suggestions / help on how to track down why this happens?


Operating System: Mac OS Sierra 10.12.4
Interface Version: rstan (Version 2.15.1, packaged: 2017-04-19 05:03:57 UTC, GitRev: 2e1f913d3ca3)
Output of writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”))):

Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/Users/daniel/.R/Makevars': No such file or directory

Output of devtools::session_info("rstan”):

Session info ------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.0 (2017-04-21)
 system   x86_64, darwin15.6.0        
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2017-05-10                  

Packages ----------------------------------------------------------------------
 package      * version   date       source        
 BH             1.62.0-1  2016-11-19 CRAN (R 3.4.0)
 colorspace     1.3-2     2016-12-14 CRAN (R 3.4.0)
 dichromat      2.0-0     2013-01-24 CRAN (R 3.4.0)
 digest         0.6.12    2017-01-27 CRAN (R 3.4.0)
 ggplot2      * 2.2.1     2016-12-30 CRAN (R 3.4.0)
 graphics     * 3.4.0     2017-04-21 local         
 grDevices    * 3.4.0     2017-04-21 local         
 grid           3.4.0     2017-04-21 local         
 gridExtra      2.2.1     2016-02-29 CRAN (R 3.4.0)
 gtable         0.2.0     2016-02-26 CRAN (R 3.4.0)
 inline         0.3.14    2015-04-13 CRAN (R 3.4.0)
 labeling       0.3       2014-08-23 CRAN (R 3.4.0)
 lattice        0.20-35   2017-03-25 CRAN (R 3.4.0)
 lazyeval       0.2.0     2016-06-12 CRAN (R 3.4.0)
 magrittr       1.5       2014-11-22 CRAN (R 3.4.0)
 MASS           7.3-47    2017-02-26 CRAN (R 3.4.0)
 Matrix         1.2-9     2017-03-14 CRAN (R 3.4.0)
 methods      * 3.4.0     2017-04-21 local         
 munsell        0.4.3     2016-02-13 CRAN (R 3.4.0)
 plyr           1.8.4     2016-06-08 CRAN (R 3.4.0)
 RColorBrewer   1.1-2     2014-12-07 CRAN (R 3.4.0)
 Rcpp           0.12.10   2017-03-19 CRAN (R 3.4.0)
 RcppEigen      0.3.3.3.0 2017-05-01 CRAN (R 3.4.0)
 reshape2       1.4.2     2016-10-22 CRAN (R 3.4.0)
 rstan        * 2.15.1    2017-04-19 CRAN (R 3.4.0)
 scales         0.4.1     2016-11-09 CRAN (R 3.4.0)
 StanHeaders  * 2.15.0-1  2017-04-19 CRAN (R 3.4.0)
 stats        * 3.4.0     2017-04-21 local         
 stats4         3.4.0     2017-04-21 local         
 stringi        1.1.5     2017-04-07 CRAN (R 3.4.0)
 stringr        1.2.0     2017-02-18 CRAN (R 3.4.0)
 tibble         1.3.0     2017-04-01 CRAN (R 3.4.0)
 tools          3.4.0     2017-04-21 local         
 utils        * 3.4.0     2017-04-21 local   

#2

What if you do it with a simpler model but call gc() before the second run?


#3

Not always. I got it to crash once. I’m not sure what’s going on.


#4

@syclik have you been able to figure out what is happening here? I am having a similar problem. The models sample, but when it reaches the last in the set it seems to segfault without finishing the sampling (or at least returning the sampling results). Also using a Mac (OS Sierra 10.12.6) with Rstan 2.16.2


#6

Nope. I reinstalled and it hasn’t happened since.


#7

Reinstalled Rstan, R, or clang?


#8

RStan.

I really wish I had an explanation, but the depths of linking code from R still escapes me.


#9

I hear you there. Thanks for the insight - I’ll give that a try and see if it works!


#10

Tried reinstalling - updated Xcode and reinstalled RStan and still getting the segfault message. Not sure what else to try here. Working on setting it up on PC to see if I get the same problem.


#11

by any chance do you have a brew or port installed g++ version on your system? Maybe one of the libraries aren’t compatible.


#12

I’m not sure how to check that?


#13

Can you post the actual messages you get and a backtrace from running this in a debugger? There are a variety of reasons segfaults could happen so we need something else to help you. If you’re not sure it’s ok, … it’s been a while since I’ve done that on a mac (and actually I don’t have a mac right now…) so it’ll take some figuring out to help you.


#14

I’ve been able to run the looped models on a PC without incident, so this must be something with my Mac installation. @sakrejda, I’m happy to post the backtrace, but don’t know how to get the backtrace as R aborts at the segfault (which is where I would normally run debugger). Thanks for your continued assistance.


#15

I don’t know the procedure on a Mac, I’ll look it up tonight if nobody else
says first.