Windows users in my courses have had problems with the following model crashing RStudio,

functions {
// Difference between one-sided Gaussian tail probability and target probability
vector tail_delta(vector y, vector theta, real[] x_r, int[] x_i) {
vector[1] deltas;
deltas[1] = 2 * (normal_cdf(theta[1], 0, exp(y[1])) - 0.5) - 0.99;
return deltas;
}
}
transformed data {
vector[1] y_guess = [log(5)]'; // Initial guess of Gaussian standard deviation
vector[1] theta = [15]'; // Target quantile
vector[1] y;
real x_r[0];
int x_i[0];
// Find Gaussian standard deviation that ensures 99% probabilty below 15
y = algebra_solver(tail_delta, y_guess, theta, x_r, x_i);
print("Standard deviation = ", exp(y[1]));
}
generated quantities {
real sigma = exp(y[1]);
}

I havenâ€™t had anyone testing it on PyStan on Windows, but it works in RStan and PyStan on OS X and at least some versions of Linux.

Can anyone who has access to Windows verify a problem and/or help isolate what the issue might be? I fear a bug in the algebraic solver thatâ€™s manifesting only in Windows.

I had weird results running this model on windows. At first it worked fine, then without changing anything it crashed RStudio a few times in a row. Now itâ€™s back to working fine. Also, when it caused R to crash it looked like the model was able to run and return the print statement.

I also want to mention that Iâ€™ve had problems with the ODE solvers crashing Rstudio on windows as well. I brought it up in this thread. When i encountered those problems it was very inconsistent. At one point I had a RK45 solver working fine; then, when I added one more parameter to the ODE system the model would compile but crash RStudio during sampling. I also couldnâ€™t get the BDF solver to work at all. Not sure if any of this is related to the algebra solver.

This does resemble the problem we have been having on Windows with ODEs, although with ODEs I could eventually reproduce the crash (although havenâ€™t been able to do anything to solve it) by running it a few times. With the algebraic_solver example, I have been able to run it 100 times in a loop without crashing by calling

for (j in 1:100) test <- stan("crash.stan", algorithm = 'Fixed_param', refresh = 0)

with just

CXX14=$(BINPREF)g++ -m$(WIN)
CXX11FLAGS = -O3

in ~/.R/Makevars.win . This is on an older desktop running Windows 10 now. Is there any obvious difference on a machine that crashes with that example?

Just for reference, in this case I was working with pretty fresh Windows 10 installs (in a computer lab with a collection of older and new iMac hardware oddly enough). I installed R, RStudio, Rtools (through the RStudio popup), and then RStan on each so the machines should have been pretty consistent. I then set Makevars as instructed in the RStan Quick Start page.

The algebraic solver model crashed on only a few of the computers, but the crashes were consistent. It crashed when run in RStudio as well as R and with chains = 1 to avoid parallelization issues. This is the same behavior Iâ€™ve encountered in the past - some Windows users are fine while some have consistent crashes of this model.

There were other issues as well. I had some exercises with a series of evolving models but the same generated quantities, and one user would experience a crash if he ran one of the models. The crash would go away if he removed the generated quantities block, but the same block would work fine in another program. Then another user had the same issue but with a different model in the sequence. In other words, the problems were consistent on one computer but varied from one computer to another.

@betanalpha, have you seen it crash with CmdStan on Windows? Itâ€™d be good to narrow whether this is a bug in the Math library or if itâ€™s some interaction with an interface.

One of the students in the course was able to reproduce the crashing behavior, but in an unexpected way.

On Windows 10, 64-bit, with R version 3.5.2, rstan_2.18.2 both models seem to run fine (they have intermittently failed in the past, but that failure canâ€™t be reproduced). On Windows 7, 64-bit, with R version 3.5.2, rstan_2.18.2 the â€śnot_working.stanâ€ť starts, deploys child processes for each chain, and then crashes RStudio reproducibly.

I have no idea why vectorization would trigger the bug, but hopefully this provides something that can be tested on other systems.