`rstream` returns error in RStudio but not in R app or from console (on a Mac)

On MacOSX using the rstream package for multiple random number streams reports an error from within RStudio (Error: C stack usage XXXXXXX is too close to the limit), but not from the terminal or the R.app.

The following code fails in RStudio but works from the terminal or the R.app

#install.packages("rstream")
library(rstream)

# Instantiate a new stream (should be able to generate a very large number
# of such streams)
s <- new("rstream.mrg32k3a")  
#> Error: C stack usage  7969260 is too close to the limit

Cstack_info()
#      size    current  direction eval_depth 
#   7969177      13168          1          2 

The Cstack_info() from the terminal (which does not return an error) is analogous.

Cstack_info()
#      size    current  direction eval_depth 
#   7969177      10048          1          2 

Any thoughts?

Regards,
Tom

TA Trikalinos

There's a long thread concluding that having rjava in namespace may be a cause. Although rstream doesn't seem to bring it in, it might help to check sessionInfo()

Thanks for the suggestion. Right after the offending code returns the error, running sessionInfo() shows no rjava:

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rstream_1.3.5

loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0   

Here's what I get under RStudio on my 2015 model Airbook with 8GB

library(rstream)
s <- new("rstream.mrg32k3a")  
s
#> 
#> Object is random stream
#> 
#>  type = rstream.mrg32k3a
#>         [mrg32k3a: RngStreams - library for multiple independent streams of Random Numbers]
#>  name = "mrg32k3a1"
#>  antithetic = FALSE
#>  increased Precision = FALSE
#> 
#>  Internal state:
#>        initial state:
#>           1579135564 1579135564 1579135564 1579135564 1579135564 1579135564 
#>        starting point of current substream:
#>           1579135564 1579135564 1579135564 1579135564 1579135564 1579135564 
#>        current state:
#>           1579135564 1579135564 1579135564 1579135564 1579135564 1579135564
Cstack_info()
#>       size    current  direction eval_depth 
#>    7969177     177584          1         63
sessionInfo()
#> R version 3.6.2 (2019-12-12)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Catalina 10.15.2
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] rstream_1.3.5
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_3.6.2  magrittr_1.5    tools_3.6.2     htmltools_0.4.0
#>  [5] yaml_2.2.0      Rcpp_1.0.3      stringi_1.4.5   rmarkdown_2.0  
#>  [9] highr_0.8       knitr_1.26      stringr_1.4.0   xfun_0.12      
#> [13] digest_0.6.23   rlang_0.4.2     evaluate_0.14

Created on 2020-01-15 by the reprex package (v0.3.0)