Rstan segfaults on macOS ventura (13.4)

I’m trying to install and run rstan on macOS 13.4 with an M1. I think I’ve installed all dependencies and correctly configured ~/.R/Makevars, but when I try to run the example to test installation, I get a segfault.

I’ve set up a repo with, I think, all necessary info, including my renv, here: GitHub - JoFrhwld/rstan_install

Session info:

sessionInfo()
# R version 4.3.0 (2023-04-21)
# Platform: aarch64-apple-darwin20 (64-bit)
# Running under: macOS Ventura 13.4
#
# Matrix products: default
# BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
# LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
#

Contents of ~/.R/Makevars

readLines("~/.R/Makevars")
# [1] ""
# [2] "CXX14FLAGS += -O3 -mtune=native -arch arm64 -ftemplate-depth-256"

Locations & version of clang++ and gfortran

system("which gfortran")
# /usr/local/bin/gfortran

system("gfortran --version")
# GNU Fortran (GCC) 12.2.0
# Copyright (C) 2022 Free Software Foundation, Inc.
# This is free software; see the source for copying conditions.  There is NO
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

system("which clang++")
# /usr/bin/clang++

system("clang++ --version")
# Apple clang version 14.0.3 (clang-1403.0.22.14.1)
# Target: arm64-apple-darwin22.5.0
# Thread model: posix
# InstalledDir: /Library/Developer/CommandLineTools/usr/bin

rstan installs with no problem, but when I run the example model, it gets to the point of sampling, then segfaults. The full session info can be seen here: rstan_install/full_session.txt at main · JoFrhwld/rstan_install · GitHub

1 Like

Have you got any luck? I’m having the same issue…

I’m having the same issue.

@JoFrhwld @Julian-san I found my solution here: R crashes during sampling · Issue #1070 · stan-dev/rstan · GitHub

1 Like

That did the trick! Thanks!!!