Skip to content
Prev 10744 / 10988 Next

[Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

We can try to take V8 out of the equation, and see what actually
causes the change. V8 uses (and tests!) the Rcpp feature to call an R
function from C++. This behaves quite differently when using
RCPP_UNWIND_PROTECT.

Here is a dummy package to demonstrate this: https://github.com/jeroen/uptest

The use case is simple: we want to call some R function from C++, and
if it fails, catch the error message and deal with it in C++. I
suspect there are more packages doing this, but perhaps they are not
testing this case.

The example from uptest above show that when we compile with
RCPP_UNWIND_PROTECT, any R error is always printed directly to the
console. Even if we catch the Rcpp::LongjumpException in C++, the R
error still seems to bubble up (as Iñaki also noted). I think this is
at least surprising.

Then I am not sure what we do in C++ now with this
Rcpp::LongjumpException if we catch it. We certainly don't want to
unwind all the way in the middle of running the javascript code. The
JavaScript code should be able to catch the R error, and continue
running the script.

Anyway if you want to make RCPP_UNWIND_PROTECT the default, I can
obviously opt-out in V8, but as an Rcpp user I am not convinced this
is an improvement.
On Tue, Feb 1, 2022 at 6:52 PM Dirk Eddelbuettel <edd at debian.org> wrote: