|
1 | 1 |
|
2 | 2 | 2018-05-31 Lionel Henry < [email protected]>
|
3 | 3 |
|
4 |
| - * inst/include/Rcpp/api/meat/Rcpp_eval.h: Unguard Rcpp_fast_eval(). |
5 |
| - |
6 |
| - Unlike Rcpp_eval(), Rcpp_fast_eval() does not evaluate R code within |
7 |
| - tryCatch() in order to avoid the catching overhead. R longjumps are now |
8 |
| - correctly intercepted and rethrown. Following this change the C++ stack |
9 |
| - is now safely unwound when a longjump is detected while calling into R |
10 |
| - code. This includes the following cases: caught condition of any class, |
11 |
| - long return, restart jump, debugger exit. |
12 |
| - |
13 |
| - Rcpp_eval() also uses the protect-unwind API under the hood in order to |
14 |
| - gain safety. It is fully backward-compatibile and still catches errors |
15 |
| - and interrupts to rethrow them as typed C++ exceptions. If you don't |
16 |
| - need to catch those, consider using Rcpp_fast_eval() instead to avoid |
17 |
| - the catching overhead. |
18 |
| - |
19 |
| - These improvements are only available for R 3.5.0 and greater. You also |
20 |
| - need to explicitly define `RCPP_PROTECTED_EVAL` before including Rcpp.h. |
21 |
| - When compiled with old versions of R, Rcpp_fast_eval() always falls back |
22 |
| - to Rcpp_eval(). This is in contrast to internal::Rcpp_eval_impl() which |
23 |
| - falls back to Rf_eval() and which is used in performance-sensititive |
24 |
| - places. |
| 4 | + * inst/include/Rcpp/api/meat/Rcpp_eval.h: Fix protected evaluation. |
| 5 | + |
| 6 | + Setting `RCPP_PROTECTED_EVAL` before including Rcpp.h enables a new R |
| 7 | + 3.5 API for safe evaluation of R code. R longjumps are now correctly |
| 8 | + intercepted and rethrown. Thanks to this the C++ stack is now safely |
| 9 | + unwound when a longjump is detected while calling into R code. This |
| 10 | + includes the following cases: thrown errors, caught condition of any |
| 11 | + class, long return, restart invokation, debugger exit. Note that this is |
| 12 | + still experimental! |
| 13 | + |
| 14 | + When `RCPP_PROTECTED_EVAL` is enabled, Rcpp_eval() uses the |
| 15 | + protect-unwind API under the hood in order to gain safety. It is fully |
| 16 | + backward-compatibile and still catches errors and interrupts to rethrow |
| 17 | + them as typed C++ exceptions. If you don't need to catch those, consider |
| 18 | + using Rcpp_fast_eval() instead to avoid the catching overhead. |
| 19 | + |
| 20 | + Rcpp_fast_eval() is a wrapper around Rf_eval(). Unlike Rcpp_eval(), it |
| 21 | + does not evaluate R code within tryCatch() and thus avoids the overhead |
| 22 | + of wrapping and evaluating the expression in a tryCatch() call. When |
| 23 | + Rcpp is compiled with a lower version than R 3.5, Rcpp_fast_eval() falls |
| 24 | + back to Rf_eval() without any protection from long jumps, even when |
| 25 | + `RCPP_PROTECTED_EVAL` is set. Either add R 3.5 to your `Depends` or make |
| 26 | + sure the legacy Rcpp_eval() function is called instead of Rcpp_fast_eval() |
| 27 | + when your package is compiled with an older version of R. |
25 | 28 |
|
26 | 29 | Note that Rcpp_fast_eval() behaves a bit differently to Rcpp_eval(). The
|
27 | 30 | former has the semantics of the C function Rf_eval() whereas the latter
|
|
0 commit comments