rstan icon indicating copy to clipboard operation
rstan copied to clipboard

segfault "memory not mapped" example(stan_model) Ubuntu 20.04

Open bransonf opened this issue 2 years ago • 1 comments

Summary:

On a bare install of Ubuntu 20.04 + R, the example code example(stan_model, package = "rstan", run.dontrun = TRUE) produces a segfault.

Description:

The only additional information I can provide is that it only happens when exiting the R session - so possibly somewhere at or during garbage collection/cleanup?

I have also tried github releases and compiling directly from the tarball here

In hunting for similar issues I'm come across recommendations to reinstall Rcpp and that their is a potential compiler conflict. If this is the case I still have not come across a set of MAKEVARS that satisfies this.

Reproducible Steps:

Dockerfile

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt update && apt install -yqq --no-install-recommends libcurl4-openssl-dev r-base-dev
RUN R -e 'install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))'
CMD ["tail", "-f", "/dev/null"]
docker build -t stan_segfault .
docker run -d --name stan_segfault stan_segfault
docker exec stan_segfault R -e 'example(stan_model, package = "rstan", run.dontrun = TRUE)'

Current Output:

*** caught segfault ***
address 0x18, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault

Expected Output:

Not to segfault.

RStan Version:

2.26.13

R Version:

4.2.1 (have reproduced with all of 4.1.x - latest)

Operating System:

Ubuntu 20.04

bransonf avatar Jul 20 '22 15:07 bransonf

I also encountered this segfault after installing RStan lastest development version (2.26.21) via

install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

This segfault can be avoided by turning off options(mc.cores = parallel::detectCores()).

Installing RStan CRAN version (2.21.8) will not produce the above segfault. But this version does not support the new array syntax, and I have to use cmdstanr package to compile stan code.

R Version: 4.2.3

Operating System: Ubuntu 20.04

caijun avatar Mar 30 '23 05:03 caijun