RStan crashes on trivially simple model

RStan is crashing for me on all model files. Sometimes it gives this message:

*** caught segfault ***
address 0x20, cause ‘memory not mapped’

Traceback:
1: Module(module, mustStart = TRUE)
2: .getModulePointer(x)
3: <S4 object of class “Module”>$stan_fit4modelb8a464cd50a4_b524cd829fcb9f50f6761f2451b62eec
4: <S4 object of class “Module”>stan_fit4modelb8a464cd50a4_b524cd829fcb9f50f6761f2451b62eec 5: eval(call("“, mod, paste(“stan_fit4”, model_cppname, sep = “”)))
6: eval(call(”$", mod, paste(“stan_fit4”, model_cppname, sep = “”)))
7: object@mk_cppmodule(object)
8: .local(object, …)
9: 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, …)
10: 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, …)
11: stan(model_code = scode, iter = 10, verbose = FALSE)

Other times it just seg faults with no message. For example, it will seg fault if I try to fit this simple model from the RStan help page:

 library(rstan)
 scode <- "
 parameters {
   real y[2]; 
 } 
 model {
   y[1] ~ normal(0, 1);
   y[2] ~ double_exponential(0, 2);
 } 
 "
 fit1 <- stan(model_code = scode, iter = 10, verbose = FALSE) 

Segmentation fault (core dumped)

rstan (Version 2.17.3, GitRev: 2e1f913d3ca3)

That is usually a result of Rcpp being compiled with a different compiler or a different set of compiler settings that rstan.

Yes, the problem seems to have gone away after I updated Rcpp.

Thanks!

Hi!

I’m quite new to RStan but I think I’ve encountered a similar issue.

*** caught segfault ***
address 0x18, cause ‘memory not mapped’
An irrecoverable exception occurred. R is aborting now …

Although it appears after a Stan object has been created on my working environment. Below is my session info. I have loaded the last version of Rcpp, so that shouldn’t be the issue, no? Any ideas?

Any help would be super appreciated! Thanks!

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] shinystan_2.6.0 shiny_1.5.0 pROC_1.18.0 loo_2.5.1 bayesplot_1.9.0
[6] rstanarm_2.21.3 forcats_0.5.1 stringr_1.4.0 purrr_0.3.4 readr_2.1.2
[11] tidyr_1.2.0 tibble_3.1.7 ggplot2_3.3.6 tidyverse_1.3.1 readxl_1.4.0
[16] hBayesDM_1.1.1 Rcpp_1.0.9 reshape2_1.4.4 rstan_2.26.13 StanHeaders_2.26.13
[21] data.table_1.14.2 dplyr_1.0.9

loaded via a namespace (and not attached):
[1] nlme_3.1-159 matrixStats_0.62.0 fs_1.5.2 xts_0.12.1 lubridate_1.8.0
[6] threejs_0.3.3 httr_1.4.3 tools_3.6.3 backports_1.4.1 DT_0.23
[11] utf8_1.2.2 R6_2.5.0 DBI_1.1.2 colorspace_2.0-3 withr_2.5.0
[16] tidyselect_1.1.2 gridExtra_2.3 prettyunits_1.1.1 processx_3.5.3 curl_4.3.2
[21] compiler_3.6.3 cli_3.3.0 rvest_1.0.2 shinyjs_2.1.0 xml2_1.3.3
[26] colourpicker_1.1.1 checkmate_2.1.0 scales_1.2.0 dygraphs_1.1.1.6 ggridges_0.5.3
[31] callr_3.7.0 digest_0.6.27 minqa_1.2.4 base64enc_0.1-3 pkgconfig_2.0.3
[36] htmltools_0.5.1 lme4_1.1-30 dbplyr_2.1.1 fastmap_1.0.1 htmlwidgets_1.5.4
[41] rlang_1.0.2 rstudioapi_0.13 generics_0.1.2 zoo_1.8-10 jsonlite_1.7.2
[46] gtools_3.9.2 crosstalk_1.2.0 inline_0.3.19 magrittr_2.0.1 Matrix_1.5-1
[51] munsell_0.5.0 fansi_1.0.3 lifecycle_1.0.1 stringi_1.7.8 MASS_7.3-58
[56] pkgbuild_1.3.1 plyr_1.8.7 grid_3.6.3 parallel_3.6.3 promises_1.1.1
[61] crayon_1.5.1 miniUI_0.1.1.1 lattice_0.20-45 splines_3.6.3 haven_2.5.0
[66] hms_1.1.1 ps_1.7.0 pillar_1.7.0 igraph_1.3.1 boot_1.3-28
[71] markdown_1.1 codetools_0.2-18 stats4_3.6.3 rstantools_2.2.0 reprex_2.0.1
[76] glue_1.6.2 V8_4.2.0 RcppParallel_5.1.5 modelr_0.1.8 nloptr_2.0.3
[81] vctrs_0.4.1 tzdb_0.3.0 httpuv_1.5.5 cellranger_1.1.0 gtable_0.3.0
[86] assertthat_0.2.1 mime_0.9 xtable_1.8-4 broom_0.8.0 later_1.1.0.1
[91] survival_3.4-0 shinythemes_1.2.0 ellipsis_0.3.2

Did you find a solution for this? I just started having this problem. It’s super weird.