C Stack Trace Errors

What could cause the following behavior? Unfortunately, I can’t share the code. But all of a sudden, I’m unable to successfully run brms on the same examples I used to be able to.

I have:

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

And below is the run log. I try to fit a model twice, and they seem to run fine. The problem seems to occur afterward.

Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.2, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
Do not specify '-march=native' in 'LOCAL_CPPFLAGS' or a Makevars file
Loading required package: Rcpp
Loading 'brms' package (version 2.14.4). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').

Attaching package: 'brms'

The following object is masked from 'package:rstan':

    loo

The following object is masked from 'package:stats':

    ar

Loading required package: usethis
Compiling Stan program...
Warning message:
In system(paste(cmd, "-n")) : 'make' not found
Start sampling
starting worker pid=11432 on localhost:11102 at 11:23:20.635
starting worker pid=9212 on localhost:11102 at 11:23:21.047
starting worker pid=14828 on localhost:11102 at 11:23:21.500
starting worker pid=13952 on localhost:11102 at 11:23:21.955

SAMPLING FOR MODEL '27306ff5df2e1c257221e6aa1f6284d4' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 0 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Chain 1: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 1: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 1: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 1: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 1: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 1: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 1: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 1: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 1: Iteration: 2800 / 4000 [ 70%]  (Sampling)

SAMPLING FOR MODEL '27306ff5df2e1c257221e6aa1f6284d4' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 0 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 1: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 2: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 1: Iteration: 3600 / 4000 [ 90%]  (Sampling)
Chain 2: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 1: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 1: 
Chain 1:  Elapsed Time: 0.172 seconds (Warm-up)
Chain 1:                0.151 seconds (Sampling)
Chain 1:                0.323 seconds (Total)
Chain 1: 
Chain 2: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 2: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 2: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 2: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 2: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 2: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 2: Iteration: 2800 / 4000 [ 70%]  (Sampling)
Chain 2: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 2: Iteration: 3600 / 4000 [ 90%]  (Sampling)
Chain 2: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 2: 
Chain 2:  Elapsed Time: 0.184 seconds (Warm-up)
Chain 2:                0.164 seconds (Sampling)
Chain 2:                0.348 seconds (Total)
Chain 2: 

SAMPLING FOR MODEL '27306ff5df2e1c257221e6aa1f6284d4' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 0 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 
Chain 3: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 3: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 3: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 3: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 3: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 3: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 3: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 3: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 3: Iteration: 2800 / 4000 [ 70%]  (Sampling)
Chain 3: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 3: Iteration: 3600 / 4000 [ 90%]  (Sampling)
Chain 3: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 3: 
Chain 3:  Elapsed Time: 0.157 seconds (Warm-up)
Chain 3:                0.144 seconds (Sampling)
Chain 3:                0.301 seconds (Total)
Chain 3: 

SAMPLING FOR MODEL '27306ff5df2e1c257221e6aa1f6284d4' NOW (CHAIN 4).
Chain 4: 
Chain 4: Gradient evaluation took 0 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4: 
Chain 4: 
Chain 4: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 4: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 4: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 4: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 4: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 4: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 4: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 4: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 4: Iteration: 2800 / 4000 [ 70%]  (Sampling)
Chain 4: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 4: Iteration: 3600 / 4000 [ 90%]  (Sampling)
Chain 4: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 4: 
Chain 4:  Elapsed Time: 0.157 seconds (Warm-up)
Chain 4:                0.156 seconds (Sampling)
Chain 4:                0.313 seconds (Total)
Chain 4: 
Compiling Stan program...
Warning message:
In system(paste(cmd, "-n")) : 'make' not found
Start sampling
starting worker pid=1656 on localhost:11102 at 11:24:06.261
starting worker pid=10868 on localhost:11102 at 11:24:06.685
starting worker pid=15252 on localhost:11102 at 11:24:07.062
starting worker pid=15980 on localhost:11102 at 11:24:07.468

SAMPLING FOR MODEL '5705fb2064205c5f40a89a50756107f7' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 0 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Chain 1: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 1: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 1: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 1: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 1: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 1: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 1: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 1: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 1: Iteration: 2800 / 4000 [ 70%]  (Sampling)
Chain 1: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 1: Iteration: 3600 / 4000 [ 90%]  (Sampling)

SAMPLING FOR MODEL '5705fb2064205c5f40a89a50756107f7' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 0 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 2: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 1: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 1: 
Chain 1:  Elapsed Time: 0.157 seconds (Warm-up)
Chain 1:                0.14 seconds (Sampling)
Chain 1:                0.297 seconds (Total)
Chain 1: 
Chain 2: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 2: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 2: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 2: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 2: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 2: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 2: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 2: Iteration: 2800 / 4000 [ 70%]  (Sampling)
Chain 2: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 2: Iteration: 3600 / 4000 [ 90%]  (Sampling)
Chain 2: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 2: 
Chain 2:  Elapsed Time: 0.17 seconds (Warm-up)
Chain 2:                0.156 seconds (Sampling)
Chain 2:                0.326 seconds (Total)
Chain 2: 

SAMPLING FOR MODEL '5705fb2064205c5f40a89a50756107f7' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 0 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 
Chain 3: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 3: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 3: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 3: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 3: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 3: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 3: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 3: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 3: Iteration: 2800 / 4000 [ 70%]  (Sampling)
Chain 3: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 3: Iteration: 3600 / 4000 [ 90%]  (Sampling)
Chain 3: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 3: 
Chain 3:  Elapsed Time: 0.143 seconds (Warm-up)
Chain 3:                0.15 seconds (Sampling)
Chain 3:                0.293 seconds (Total)
Chain 3: 

SAMPLING FOR MODEL '5705fb2064205c5f40a89a50756107f7' NOW (CHAIN 4).
Chain 4: 
Chain 4: Gradient evaluation took 0 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4: 
Chain 4: 
Chain 4: Iteration:    1 / 4000 [  0%]  (Warmup)
Chain 4: Iteration:  400 / 4000 [ 10%]  (Warmup)
Chain 4: Iteration:  800 / 4000 [ 20%]  (Warmup)
Chain 4: Iteration: 1200 / 4000 [ 30%]  (Warmup)
Chain 4: Iteration: 1600 / 4000 [ 40%]  (Warmup)
Chain 4: Iteration: 2000 / 4000 [ 50%]  (Warmup)
Chain 4: Iteration: 2001 / 4000 [ 50%]  (Sampling)
Chain 4: Iteration: 2400 / 4000 [ 60%]  (Sampling)
Chain 4: Iteration: 2800 / 4000 [ 70%]  (Sampling)
Chain 4: Iteration: 3200 / 4000 [ 80%]  (Sampling)
Chain 4: Iteration: 3600 / 4000 [ 90%]  (Sampling)
Chain 4: Iteration: 4000 / 4000 [100%]  (Sampling)
Chain 4: 
Chain 4:  Elapsed Time: 0.196 seconds (Warm-up)
Chain 4:                0.165 seconds (Sampling)
Chain 4:                0.361 seconds (Total)
Chain 4: 
Loading required package: survival

Attaching package: 'survival'

The following object is masked from 'package:brms':

    kidney


==== C stack trace ===============================

	(No symbol) [0x0x472f730]
	R_RunWeakRefFinalizer [0x0xc7f326f+383]
	R_RunWeakRefFinalizer [0x0xc7f3507+1047]
	R_initAssignSymbols [0x0xc7b67a9+72761]
	Rf_eval [0x0xc7bb841+369]
	R_cmpfun1 [0x0xc7bd547+1191]
	Rf_applyClosure [0x0xc7be7aa+442]
	R_has_methods_attached [0x0xc7fa088+920]
	R_has_methods_attached [0x0xc7fa5d4+2276]
	R_initAssignSymbols [0x0xc7a504f+1247]
	R_initAssignSymbols [0x0xc7b2cee+57726]
	Rf_eval [0x0xc7bb841+369]
	R_cmpfun1 [0x0xc7bd547+1191]
	Rf_applyClosure [0x0xc7be7aa+442]
	R_initAssignSymbols [0x0xc7b2994+56868]
	R_forceAndCall [0x0xc7c3896+10726]
	R_forceAndCall [0x0xc7c3eb6+12294]
	Rf_eval [0x0xc7bbc25+1365]
	Rf_ReplIteration [0x0xc7e4c61+673]
	Rf_ReplIteration [0x0xc7e4fc1+1537]
	run_Rmainloop [0x0xc7e505d+77]
	(No symbol) [0x0x4016da]
	(No symbol) [0x0x4038bf]
	(No symbol) [0x0x4013c5]
	(No symbol) [0x0x40152b]
	BaseThreadInitThunk [0x0x7ffa1b327974+20]
	RtlUserThreadStart [0x0x7ffa1c9fa271+33]

The messages just before that error suggest it is coming from another R package, or from some function inside R. I would suggest

  • reinstalling all of your R packages.
  • figuring out what is giving you the make not found error, which may be illuminating.

Thanks. I’m running the following command:

install.packages(pkgs=unname(installed.packages()[, "Package"]))

As to missing make, for Rtools35, I noticed that C:\Rtools\mingw_32\bin and C:\Rtools\mingw_64\bin have no make.exe. It’s in C:\Rtools\bin. For Rtools40, it’s in C:\rtools40\usr\bin. Maybe this has something to do with how BINPREF is set. Will investigate.

rstan is giving me problems. It requires CXX14 to be defined. I had renamed Makevars.win to Makevars.win.bak following another thread’s suggestion.

> install.packages(pkgs="rstan")

  There is a binary version available but the source version is later:
      binary source needs_compilation
rstan 2.19.3 2.21.2              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package 'rstan'

trying URL 'https://cran.case.edu/src/contrib/rstan_2.21.2.tar.gz'
Content type 'application/x-gzip' length 1152008 bytes (1.1 MB)
downloaded 1.1 MB

In R CMD INSTALL
* installing *source* package 'rstan' ...
** package 'rstan' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
Error in .shlib_internal(args) :
  C++14 standard requested but CXX14 is not defined
* removing 'C:/Users/abreucbr/Documents/R/R-3.5.0/library/rstan'
* restoring previous 'C:/Users/abreucbr/Documents/R/R-3.5.0/library/rstan'

The downloaded source packages are in
        'C:\Users\abreucbr\AppData\Local\Temp\RtmpAVbpDP\downloaded_packages'
Warning message:
In install.packages(pkgs = "rstan") :
  installation of package 'rstan' had non-zero exit status

So I renamed it back and it contains the following:

CXX14FLAGS=-O3
CXX14 = g++ -m$(WIN) -std=c++14
CXX11FLAGS=-O3

After renaming it back, I get the following error:

> install.packages(pkgs="rstan")

  There is a binary version available but the source version is later:
      binary source needs_compilation
rstan 2.19.3 2.21.2              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package 'rstan'

trying URL 'https://cran.case.edu/src/contrib/rstan_2.21.2.tar.gz'
Content type 'application/x-gzip' length 1152008 bytes (1.1 MB)
downloaded 1.1 MB

In R CMD INSTALL
* installing *source* package 'rstan' ...
** package 'rstan' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
g++ -m32 -std=c++14  -I"C:/Users/abreucbr/DOCUME~1/R/R-35~1.0/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS  -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/abreucbr/Documents/R/R-3.5.0/library/Rcpp/include" -I"C:/Users/abreucbr/Documents/R/R-3.5.0/library/RcppEigen/include" -I"C:/Users/abreucbr/Documents/R/R-3.5.0/library/BH/include" -I"C:/Users/abreucbr/Documents/R/R-3.5.0/library/StanHeaders/include" -I"C:/Users/abreucbr/Documents/R/R-3.5.0/library/RcppParallel/include"     -DRCPP_PARALLEL_USE_TBB=1   -O3 -c sparse_extractors.cpp -o sparse_extractors.o
In file included from C:/Users/abreucbr/Miniconda3/Library/mingw-w64/include/c++/5.3.0/random:49:0,
                 from C:/Users/abreucbr/Miniconda3/Library/mingw-w64/include/c++/5.3.0/bits/stl_algo.h:66,
                 from C:/Users/abreucbr/Miniconda3/Library/mingw-w64/include/c++/5.3.0/algorithm:62,
                 from C:/Users/abreucbr/Documents/R/R-3.5.0/library/RcppEigen/include/Eigen/Core:288,
                 from C:/Users/abreucbr/Documents/R/R-3.5.0/library/RcppEigen/include/Eigen/Dense:1,
                 from C:/Users/abreucbr/Documents/R/R-3.5.0/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13,
                 from C:/Users/abreucbr/Documents/R/R-3.5.0/library/StanHeaders/include/stan/math/prim/mat/meta/append_return_type.hpp:4,
                 from C:/Users/abreucbr/Documents/R/R-3.5.0/library/StanHeaders/include/stan/math/prim/meta.hpp:9,
                 from C:/Users/abreucbr/Documents/R/R-3.5.0/library/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:4,
                 from sparse_extractors.cpp:2:
C:/Users/abreucbr/Miniconda3/Library/mingw-w64/include/c++/5.3.0/bits/random.h:106:26: error: expected unqualified-id before '__int128'
       { typedef unsigned __int128 type; };
                          ^
make: *** [C:/Users/abreucbr/DOCUME~1/R/R-35~1.0/etc/i386/Makeconf:215: sparse_extractors.o] Error 1
ERROR: compilation failed for package 'rstan'
* removing 'C:/Users/abreucbr/Documents/R/R-3.5.0/library/rstan'
* restoring previous 'C:/Users/abreucbr/Documents/R/R-3.5.0/library/rstan'

Why is it looking for headers in C:/Users/abreucbr/Miniconda3/Library/mingw-w64/include?

The miniconda installation messed with the configuration files. However, you should be able to install binary rstan packages for Windows from

Although my guess is that you will have miniconda-related problems later.

What a nightmare…!

How about install.packages("rstan", type = "win.binary", dependencies = TRUE)?

That seems to have worked.

install.packages(pkgs=unname(installed.packages()[, "Package"]), type = "win.binary", dependencies = TRUE)

My example isn’t crashing again.