# Error: protection stack overflow with new package version of rstanarm

**URL:** <https://discourse.mc-stan.org/t/error-protection-stack-overflow-with-new-package-version-of-rstanarm/3050>\
**Category:** rstanarm\
**Created:** [January 19, 2018, 2:52pm UTC](https://discourse.mc-stan.org/t/error-protection-stack-overflow-with-new-package-version-of-rstanarm/3050 "2018-01-19T14:52:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yve](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@Yve](https://discourse.mc-stan.org/u/Yve)\
**Post date:** [January 19, 2018, 2:52pm UTC](https://discourse.mc-stan.org/t/error-protection-stack-overflow-with-new-package-version-of-rstanarm/3050/1 "2018-01-19T14:52:03Z")

</div>

I need to reestimate several models after updating to the newest rstanarm package version (see [Error in if (is.mer(x) && x$stan\_function != "stan\_gamm4") after updating package version](http://discourse.mc-stan.org/t/error-in-if-is-mer-x-x-stan-function-stan-gamm4-after-updating-package-version/2989)).

However, I have trouble running the same models with the new version of rstanarm. The models all end with an error concerning memory:

Error: protect(): protection stack overflow

I use the same machine as before, same data, etc.  
The use of simpler models, less chains, less iterations, … give the same message.

R uses maximum memory available as with the previous package version:

> memory.limit()  
> [1] 3956

which has never been a problem before.

One of the old models was e.g. as following:  
model2 ← stan\_lmer(CWM.bodysize2 ~ elevation\_z + NDVI\_ARC\_z +(1|year/month) + (1|plot), algorithm=“sampling”, data=Hop, na.action=na.omit, chains=4, iter=2000, prior=normal(), prior\_ops=prior\_options(scaled=T))

Model under new version of rstanarm is e.g.:  
model2 ← stan\_lmer(CWM.bodysize2 ~ elevation\_z + NDVI\_ARC\_z + (1|plot) +(1|year/month), algorithm=“sampling”, data=Hop, na.action=na.omit, chains=4, iter=2000, prior =NULL)

On the other hand, running other (example) models works. E.g.  
default\_prior\_test ← stan\_glm(mpg ~ wt + am, data = mtcars, chains = 1)

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [February 7, 2018, 8:57pm UTC](https://discourse.mc-stan.org/t/error-protection-stack-overflow-with-new-package-version-of-rstanarm/3050/2 "2018-02-07T20:57:58Z")

</div>

It looks like the R devs missed this one. @jonah or @bgoodri — any ideas here? If nobody responds, the way to escalate is to open a bug report on the stan-dev/rstanarm GitHub repo.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [February 7, 2018, 9:05pm UTC](https://discourse.mc-stan.org/t/error-protection-stack-overflow-with-new-package-version-of-rstanarm/3050/3 "2018-02-07T21:05:08Z")

</div>

I haven’t seen that before with Stan stuff. Everyone on Google says to start R via

```
R --max-ppsize=50000

```

and then everyone says that does not help.

---

<div class="post-metadata">

**Author:** ![Yve](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@Yve](https://discourse.mc-stan.org/u/Yve)\
**Post date:** [February 22, 2018, 8:39am UTC](https://discourse.mc-stan.org/t/error-protection-stack-overflow-with-new-package-version-of-rstanarm/3050/4 "2018-02-22T08:39:22Z")

</div>

Still, I do not have any idea WHY the “protection stack overflow” error occurred. Finally, I decided to completely deinstall and reinstall RStan on my machine. After I had also upgraded my R version, I needed to upgrade to a newer version of Rtools, followed by the usual installation of RStan and rstanarm ([https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows](https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows)). This solved the problem. However, I am still not sure what exactly caused the error.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [February 23, 2018, 8:12pm UTC](https://discourse.mc-stan.org/t/error-protection-stack-overflow-with-new-package-version-of-rstanarm/3050/5 "2018-02-23T20:12:02Z")

</div>

> [@Yve](#):
>
> However, I am still not sure what exactly caused the error.

We get that a lot. It’s just due to the deeply entangled nature of configuring a bunch of complicated packages.

Thanks for reporting back.
