-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix run now errors and interrupts #192
Conversation
The introduction of unwind protection in Rcpp required us to stop working so hard to catch and re-propagate different kinds of errors across the R->C++->R boundary. This went unnoticed for so long because the interrupt-related tests were already misbehaving on CI and on CRAN. I've now refactored the tests so that the test skipping can be narrowly scoped to just the interrupts, and even those, I'd like to try again on CI.
f873492
to
2922839
Compare
Re: remaining failures for R 4.1 and 3.6 on Windows: On these builds, having Rcpp code throw an exception that's caught by the calling R code, seems to be escaping the try/catch somehow. But only for i386, not x64!? |
Minimal repro looks like the below. It actually works when called from RStudio, but fails when called from R at a terminal or if you put it in a file and call library(later)
Rcpp::cppFunction(
depends = "later",
includes = '
#include <later_api.h>
void oof(void* data) {
throw std::runtime_error("This is a C++ exception.");
}
',
code = '
void cpp_error(int value) {
later::later(oof, 0, 0);
}
'
)
tryCatch(
{cpp_error(1); later::run_now()},
error = function(e) {message("got here")}
) |
I notice you're not using mirai::mirai(rlang::interrupt())[]
#> 'miraiInterrupt' chr ""
mirai::mirai(tools::pskill(Sys.getpid(), tools::SIGINT))[]
#> [1] TRUE Created on 2024-10-29 with reprex v2.1.1 FYI mirai handles errors entirely on the R side with a combination of with |
UPDATE: R CMD check does work on this branch for me. It was failing with Using |
@shikokuchuo Thank you for the suggestion to use After I removed those, I was able to remove almost all of the testthat skips. The only problem that still remains is that on Windows i386 only, native |
@shikokuchuo Due to a record-setting windstorm here, I have no access to Windows at the moment; my only Windows PC is a desktop and I have to leave the house with my laptop to have internet. I also will be in meetings for most of today that will require my undivided attention. Given that you already understand what's happening here much better than I do, and have also talked to @lionel-, can I leave it to you to decide the path forward for this release? As long as it works for all supported platforms including Windows 32-bit. And ideally passing the tests that are currently on this branch (rather than on main, which are using pskill and also skipping all the hard tests on ci and cran) |
Oh wow - well stay safe! We've had our first snow here in London and it's bitterly cold... Have made some further progress with Lionel. The odd behaviour on Win32 was a bit of a red flag which is why I sought out Lionel to make sure we're doing the right thing! Will provide updates, which you can pickup whenever - we'll carry on trying to get to the best solution. |
* use Rcpp::uwindProtect() * remove unwindProtect for Rcpp::function; update std::function<void(void)> calls to closely mirror their Rcpp std::function<SEXP(void)> counterparts * use BEGIN_RCCP/END_RCPP macros inside Rcpp::unwindProtect * keep const qualifier
I'm fine to merge this PR if you're ok with my replies @jcheng5. Do we need Winston (as maintainer) to kick off the revdepchecks / CRAN submission after that? |
Finally just want to confirm if we're keeping the |
As a result of testing on a selection of rhub platforms, have made a couple of further changes to get this into shape:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm re-approving as I did make this commit a16ac2c. This never caused valgrind to actually fail, but it bugged me that the results weren’t clean. I managed to track it down to something as simple as finalizers not being run on exit (no change in actual behaviour) rather than anything more involved!
Sorry for the delay, finally back home with power and internet restored. |
Thanks! Hope everything is fine and you weren't otherwise affected. |
Fixes #191