-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Downstream issues:
rstudio/shiny#1967 (comment)
rstudio/httpuv#130
This happens only under certain circumstances, when a native/Rcpp callback function is registered with the native later::later API, and an interrupt occurs within the callback.
Rcpp::cppFunction(depends = "later",
code = '
void test() {
later::later(doIt, 0, 0);
}
',
includes = '
#include <later_api.h>
void doIt(void* data) {
throw new Rcpp::internal::InterruptedException();
}
')Run test() to reproduce; you should see later: c++ exception (unknown reason) occurred while executing callback.
In the example above, we are calling throw Rcpp::internal::InterruptedException() explicitly, but it can happen through user gesture as well:
Rcpp::cppFunction(depends = "later",
code = '
void test2() {
later::later(doIt, 0, 0);
}
',
includes = '
#include <later_api.h>
void doIt(void* data) {
Rcpp::Function func("Sys.sleep");
func(5);
}
')Run test2(); later::run_now(5), and quickly hit Esc or Ctrl+C to interrupt. You should see Error in execCallbacks(timeoutSecs) : c++ exception (unknown reason).
The root cause seems to have to do with the compilation unit of the throw Rcpp::internal::InterruptedException versus that of the catch (Rcpp::internal::InterruptedException) (usually the latter is via the END_RCPP macro). A minimal repro for this problem is at https://github.com/jcheng5/exceptiontest.