[Rcpp-devel] Rf_error and Rcpp

Romain Francois romain at r-enthusiasts.com
Tue May 4 18:38:36 CEST 2010


Le 04/05/10 18:24, Dirk Eddelbuettel a écrit :
>
> On 4 May 2010 at 18:02, Romain Francois wrote:
> | Le 04/05/10 15:18, Douglas Bates a écrit :
> |>  As I understand it, we are still at risk of code in the R API that we
> |>  call in turn calling Rf_error, right?  That will have the same effect
> |>  of leaving the C++ exception stack in an inconsistent state?
> |
> | Yes. While we do our best to isolate this problem, it is still a
> | possibility.
> |
> | We need to track down all calls to R APIs in Rcpp and be careful about
> | potential jumps. This is probably going to be difficult to track, fix or
> | even test that we fixed it, because apparently the incubating period is
> | unpredictable (if I understand what Simon wrote) and the symptoms could
> | be quite unrelated. should be fun.
> |
> | One thing I am not sure at all is how the old api behaves with regards
> | to exceptions and R error mechanism, and I'm not volunteering to look.
>
> A bit of separation of church and state -- the old API was used mostly in
> what I tend to call 'vertical mode': called from R in a synchronous manner,
> does some work, returns.  This leaves less scope for errors as the code was
> mostly in C++ outside the R API.  Also, most calls were from try / catch
> blocks.
>
> The new API is more ambitious and allows for more things in C++ and R
> interchangeably (and I tend to call that 'horizontal') so there is indeed a
> possibility of jumping put at the wrong time.
>
> I'm not entirely sure how to make this water-tight.

Sure. What we need to do is check R api calls, things like STRING_ELT 
might call error if the object is not a STRSXP and this would invalidate 
C++ stack (in theory ...)

One thing the old api does not do is throw declarations and we've 
noticed that this sometimes makes a difference when using dynamic 
linking, although the old api only used standard exception classes 
(range_error, etc ...) and not custom classes, so maybe that makes a 
difference.


-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9aKDM9 : embed images in Rd documents
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7



More information about the Rcpp-devel mailing list