Help with RStudio crashing

4,249 views
Skip to first unread message

anjali....@gmail.com

unread,
Feb 14, 2017, 9:00:17 PM2/14/17
to Stan users mailing list

Dear Stan Group,


When I run the attached MPLN.R and mpln.stan code via RStudio Version 1.0.136 (R version 3.3.2), code starts compiling then I get an error saying that R encountered a fatal error and the session is being aborted. I'm using a MacBook Pro with OSX 10.11.5, 16GB RAM, 2.9 GHz. However, my friend can run the exact code in her MacBook with no issues and produce perfect results. 


I found an RStan user with similar issue as mine: https://github.com/stan-dev/rstan/issues/115 According to him, changes to Makevars helped him, even though specifics are not given.  I also tried running the code through terminal and the following error is produced. Any help is appreciated. I have attached .R, .stan, Makevars and data files.  


Thanks,

A.Silva


Error when run on terminal: 

*** caught segfault ***

  address 0x1c, cause 'memory not mapped'


Traceback:

  1: FUN(X[[i]], ...)

2: lapply(name, function(id) {    v <- .Internal(getSymbolInfo(as.character(id), PACKAGE, as.logical(withRegistrationInfo)))    if (is.null(v)) {        msg <- paste("no such symbol", id)        if (length(pkgName) && nzchar(pkgName))             msg <- paste(msg, "in package", pkgName)        stop(msg, domain = NA)    }    names(v) <- c("name", "address", "package", "numParameters")[seq_along(v)]    v})

3: getNativeSymbolInfo(name, PACKAGE)

4: doTryCatch(return(expr), name, parentenv, handler)

5: tryCatchOne(expr, names, parentenv, handlers[[1L]])

6: tryCatchList(expr, classes, parentenv, handlers)

7: tryCatch(getNativeSymbolInfo(name, PACKAGE), error = function(e) e)

8: Module(module, mustStart = TRUE)

9: .getModulePointer(x)

10: <S4 object of class "Module">$stan_fit4model32209064082_trial6_vector

11: eval(expr, envir, enclos)

12: eval(call("$", mod, paste("stan_fit4", model_cppname, sep = "")))

13: object@mk_cppmodule(object)

14: .local(object, ...)

15: sampling(sm, data, pars, chains, iter, warmup, thin, seed, init,     check_data = TRUE, sample_file = sample_file, diagnostic_file = diagnostic_file,     verbose = verbose, algorithm = match.arg(algorithm), control = control,     check_unknown_args = FALSE, cores = cores, open_progress = open_progress,     include = include, ...)

16: sampling(sm, data, pars, chains, iter, warmup, thin, seed, init,     check_data = TRUE, sample_file = sample_file, diagnostic_file = diagnostic_file,     verbose = verbose, algorithm = match.arg(algorithm), control = control,     check_unknown_args = FALSE, cores = cores, open_progress = open_progress,     include = include, ...)

17: stan(file = "trial6_vector.stan", data = data1, iter = 100, chains = 1,     verbose = FALSE, refresh = -1)


Possible actions:

1: abort (with core dump, if enabled)

2: normal R exit

3: exit R without saving workspace

4: exit R saving workspace


version of the C++ compiler

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

Apple LLVM version 8.0.0 (clang-800.0.42.1)

Target: x86_64-apple-darwin15.5.0

Thread model: posix

InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin



sessionInfo()

R version 3.3.2 (2016-10-31)

Platform: x86_64-apple-darwin13.4.0 (64-bit)

Running under: OS X El Capitan 10.11.5


locale:

[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8


attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods  

[7] base     


other attached packages:

[1] edgeR_3.14.0         limma_3.28.21        mclust_5.2          

[4] mnormt_1.5-4         mvtnorm_1.0-5        rstan_2.14.1        

[7] StanHeaders_2.14.0-1 ggplot2_2.2.1       


loaded via a namespace (and not attached):

 [1] Rcpp_0.12.9      codetools_0.2-15 assertthat_0.1  

 [4] grid_3.3.2       plyr_1.8.4       gtable_0.2.0    

 [7] stats4_3.3.2     scales_0.4.1     lazyeval_0.2.0  

[10] tools_3.3.2      munsell_0.4.3    parallel_3.3.2  

[13] inline_0.3.14    colorspace_1.2-6 gridExtra_2.2.1 

[16] tibble_1.2   

Makevars
mpln.stan
counts.csv
MPLN.R

Ben Goodrich

unread,
Feb 14, 2017, 9:16:37 PM2/14/17
to Stan users mailing list
Try

install.packages("Rcpp", type = "source")

Restart RStudio and run your model again.

a silva

unread,
Feb 15, 2017, 1:24:36 PM2/15/17
to stan-...@googlegroups.com
Thank you for the suggestion, Ben! I tried running data on Rstudio few different times. Majority of the time, now the program works. However, a few times RStudio stops part way with the error "R encountered a fatal error. The session was terminated". 

Same happened with running through terminal, at times it gives the error
"*** caught segfault *** address 0x1c, cause 'memory not mapped' ...".


Ben Goodrich

unread,
Feb 15, 2017, 2:17:07 PM2/15/17
to Stan users mailing list
On Wednesday, February 15, 2017 at 1:24:36 PM UTC-5, a silva wrote:
Thank you for the suggestion, Ben! I tried running data on Rstudio few different times. Majority of the time, now the program works. However, a few times RStudio stops part way with the error "R encountered a fatal error. The session was terminated". 

That is a hard thing to diagnose. It may be the case that your disk is starting to be unpredictable. Does it crash on the first run or subsequent runs of the same model?

a silva

unread,
Feb 16, 2017, 10:28:37 PM2/16/17
to stan-...@googlegroups.com
With Rstudio, it crashed the first time after I tried your suggestion. Second or third try, it started working fine and I was able to completely run the program. But once in a while, it still crash.  

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/66dgsQfr1GY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philip Boonstra

unread,
Feb 21, 2017, 9:44:31 AM2/21/17
to Stan users mailing list
Hi, I would like to chime in to this thread, too. Hopefully this information can be helpful for the development team in identifying the problem. I updated to 2.14.1 yesterday and immediately began noticing that R was crashing more frequently. At first it seemed sporadic to me, but I have been able to narrow it down such that R crashes in a similar way as described by a silva above always at the *second* time I try to run a stan model. IOW, I can compile the model fine and run it exactly once, but when I try to run it again, e.g. on a different simulated dataset, it crashes.

I rolled back to 2.13 and encountered the same problems. But when I rolled back to 2.12, I do not encounter the same problems.

I've attached an R script and Stan model that causes the problem for me (when using 2.14). The model is a simple logistic dose-response model with order constraints between dose levels. Also included as a comment in the script is the traceback for the fatal error that R encounters. I should note that I have modified my makevars as suggested by the development team to suppress compiler warnings (http://mc-stan.org/misc/warnings.html). This does not seem to be the source of my problems, however.

sessionInfo();
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X El Capitan 10.11.6

locale:
  [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
  [1] rstan_2.14.1         StanHeaders_2.14.0-1 ggplot2_2.2.1      

loaded via a namespace (and not attached):
  [1] colorspace_1.2-7 scales_0.4.1     assertthat_0.1   lazyeval_0.2.0   plyr_1.8.4       tools_3.3.2    
[7] inline_0.3.14    gtable_0.2.0     tibble_1.2       gridExtra_2.2.1  Rcpp_0.12.9      grid_3.3.2     
[13] stats4_3.3.2     munsell_0.4.3  


On Thursday, February 16, 2017 at 10:28:37 PM UTC-5, a silva wrote:
With Rstudio, it crashed the first time after I tried your suggestion. Second or third try, it started working fine and I was able to completely run the program. But once in a while, it still crash.  
On Wed, Feb 15, 2017 at 2:17 PM, Ben Goodrich <goodri...@gmail.com> wrote:
On Wednesday, February 15, 2017 at 1:24:36 PM UTC-5, a silva wrote:
Thank you for the suggestion, Ben! I tried running data on Rstudio few different times. Majority of the time, now the program works. However, a few times RStudio stops part way with the error "R encountered a fatal error. The session was terminated". 

That is a hard thing to diagnose. It may be the case that your disk is starting to be unpredictable. Does it crash on the first run or subsequent runs of the same model?

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/66dgsQfr1GY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
ConstrainedLogit.stan
test.R

Ben Goodrich

unread,
Feb 21, 2017, 10:49:38 AM2/21/17
to Stan users mailing list
Thanks. Can you try installing rstan from GitHub to see if it is still crashing?

Philip Boonstra

unread,
Feb 21, 2017, 11:30:53 AM2/21/17
to Stan users mailing list
Hi, I don't want to drive this off-topic, but I encountered troubles installing stan from github. I think the error is unrelated to the present discussion, but I'm having some trouble navigating. I used

install_github("stan-dev/rstan",subdir = "rstan/rstan")

and get the following error (which I've truncated):

stanc.cpp:4:10: fatal error: 'stan/version.hpp' file not found
#include <stan/version.hpp>
         ^
1 error generated.
make: *** [stanc.o] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rstan’
Error: Command failed (1)


I found this thread, https://github.com/stan-dev/rstan/issues/15, but I don't use MacPorts, so I'm not sure if its the root problem is common. Sorry, I'm way outside of my comfort zone now.

-Phil

Ben Goodrich

unread,
Feb 21, 2017, 1:26:47 PM2/21/17
to Stan users mailing list
On Tuesday, February 21, 2017 at 11:30:53 AM UTC-5, Philip Boonstra wrote:
Hi, I don't want to drive this off-topic, but I encountered troubles installing stan from github. I think the error is unrelated to the present discussion, but I'm having some trouble navigating. I used

install_github("stan-dev/rstan",subdir = "rstan/rstan")

and get the following error (which I've truncated):

stanc.cpp:4:10: fatal error: 'stan/version.hpp' file not found
#include <stan/version.hpp>

You need to first have installed the most up to date version of the StanHeaders package from CRAN.

Ben

Philip Boonstra

unread,
Feb 21, 2017, 1:46:58 PM2/21/17
to Stan users mailing list
Very curious. I had 2.14.0-1 of StanHeaders from CRAN installed when I got the above error.

Bob Carpenter

unread,
Feb 22, 2017, 1:07:37 PM2/22/17
to stan-...@googlegroups.com
Stan versions 2.10--2.13 had a bug in sampling that
was fixed in 2.14. Please don't use 2.10--2.13.

- Bob
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <ConstrainedLogit.stan><test.R>

Ben Goodrich

unread,
Feb 22, 2017, 5:18:04 PM2/22/17
to Stan users mailing list
On Tuesday, February 21, 2017 at 1:46:58 PM UTC-5, Philip Boonstra wrote:
Very curious. I had 2.14.0-1 of StanHeaders from CRAN installed when I got the above error.

Philip Boonstra

unread,
Feb 22, 2017, 7:34:27 PM2/22/17
to Stan users mailing list
Success! I installed 2.14 from github and my aforementioned test model now runs successfully. Thanks for you help!

Is there any rhyme or reason as to why the CRAN distribution doesn't work on my machine but the GitHub one does? Is this something local to me? (I should say also -  I didn't mean in my original post to imply a certainty that the problem was on the development side).

In any case, thanks for your help!

Bob Carpenter

unread,
Feb 22, 2017, 11:16:25 PM2/22/17
to stan-...@googlegroups.com

> On Feb 22, 2017, at 7:34 PM, Philip Boonstra <ph...@boonstras.com> wrote:
>
> Success! I installed 2.14 from github and my aforementioned test model now runs successfully. Thanks for you help!
>
> Is there any rhyme or reason as to why the CRAN distribution doesn't work on my machine but the GitHub one does? Is this something local to me? (I should say also - I didn't mean in my original post to imply a certainty that the problem was on the development side).

Don't worry---we're pretty thick skinned. Install problems and
system instability can happen for reasons ranging from C++ compiler
incompatiblity with Rcpp to loose memory connections. That makes
them hard to diagnose online.

- Bob

P.S. Most of our users follow the xkcd tech support flowchart

https://xkcd.com/627/

and then we only hear from them after they've gotten frustrated
and exited the bottom left.

We'd rather have people ask after trying hard themselves than continue
to bang their heads on their console for another 24 hours trying to go
it alone.

a silva

unread,
Feb 27, 2017, 3:03:46 PM2/27/17
to stan-...@googlegroups.com
Hello,

I tried all the above steps, including downloading rstan from GitHub, but my program still crash on RStudio. If there any other suggestions, please let me know. Thank you.

--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/66dgsQfr1GY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.

Martin Cerny

unread,
Mar 10, 2017, 4:34:14 AM3/10/17
to Stan users mailing list
Hi all,
I think I've pinned down the case where R crashes (even the latest version on GitHub). The problem is if you fit (+extract), recompile and then fit+extract twice.
I've described it in detail (with a code to reproduce it) at GitHub

Martin
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages