[Rcpp-devel] Rcpp::exception + threads = disaster
Joshua N Pritikin
jpritikin at pobox.com
Sat Feb 8 21:45:24 CET 2020
On Sat, Feb 08, 2020 at 03:28:22PM -0500, JJ Allaire wrote:
> Agreed that it would be good to have more clear docs here. Note
> that as Dirk pointed out both Writing R Extensions and
> RcppParallel docs are pretty clear about the fact that you
> shouldn't call any R APIs when in a background thread.
Rcpp::stop superficially looks like a nice way to throw C++ exceptions
that also does printf style message formatting. I didn't realize that
it calls R APIs until I looked at the implementation.
> I think the point is that the *only* reason Rcpp::stop exists is
> to do forwarding to Rf_error. If that isn't your intention it's
> strictly worse than a normal C++ exception.
Sure, but does it *have* to be that way? It seems to me that
exceptions.h line 40,
rcpp_set_stack_trace(Shield<SEXP>(stack_trace()))
could just as easily be done around macros/macros.h line 51.
More information about the Rcpp-devel
mailing list