[Rcpp-devel] Rstudio crashes with repeated calls to sourceCpp with Xptr export

Iñaki Úcar i.ucar86 at gmail.com
Mon Sep 4 11:43:31 CEST 2017


Hi,

2017-09-04 10:22 GMT+02:00 Helske, Jouni <jouni.helske at jyu.fi>:
> Hi,
>
>
> In the bssm package (https://github.com/helske/bssm), I let the users define
> a state space model via own C++ functions which are then exported as Xptr to
> R side, and passed back to C++ function for SMC/MCMC etc. Normally this
> works fine, but when user repeatedly modifies the model functions and
> re-exports them via repeated calls sourceCpp, sometimes whole Rstudio
> crashes. I haven't been able to pinpoint the reason or minimal example. Have
> anyone else experienced similar issues or is it just me i.e. error in my own
> implementations?

You can try the same by running R from the command line. If this
doesn't crash, the problem is in RStudio. You can also run RStudio
with the "-debug" flag or using valgrind to try to delimit the issue.

> Simplest case of this is the discretized SDE models, this is the function
> which user modifies:
> https://github.com/helske/bssm/blob/master/vignettes/sde_functions.cpp,  and
> the relevant parts of the package codes are in src/function_pointers.h,
> src/sde_ssm.cpp and src/R_sde.cpp (I don't really expect anyone to read
> through all of these).

Let me suggest you the RcppXPtrUtils package (on CRAN) for exporting
XPtrs without adding all the repetitive scaffolding:
http://gallery.rcpp.org//articles/passing-cpp-function-pointers-rcppxptrutils/

Regards,
Iñaki


More information about the Rcpp-devel mailing list