Skip to content
Prev 10055 / 10988 Next

[Rcpp-devel] `checkUserInterrupt()` might not be safe if Rcout is used.

What environment are you executing this on? (R in terminal, or with a GUI;
which OS?)

One thing to be cautious of is that many R APIs in graphical environments
will also call for processing of events, and this in turn can also imply a
check for, and handling of, interrupts. Rprintf() is in fact one such API
(and this is called behind the scenes by Rcout).

This implies something quite unfortunate: attempts to use any R APIs which
call for processing of events within a C++ context can cause a longjmp that
bypass C++ destructors and leave you in a bad state.

Fortunately, things will be better with the newer Rcpp evaluation system
from R 3.5 and above, thanks for R_UnwindProtect() and work from Lionel to
integrate that with the Rcpp evaluation model. See
https://github.com/RcppCore/Rcpp/pull/789 for some of the details on the
initial PR. We're still settling out some final details on the API but once
that's ready we'll have some documentation + hopefully an Rcpp gallery
example describing its use.

(We might also consider in Rcpp wrapping our calls to Rprintf() in
R_ToplevelExec() and 'catching' and 'rethrowing' interrupts seen, but this
might have some unintended side-effects)

Best,
Kevin
On Thu, Jul 26, 2018 at 8:18 AM Wush Wu <wush978 at gmail.com> wrote:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20180726/cf9fb294/attachment-0001.html>