-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
Use protect-unwind API and add Rcpp_fast_eval() #789
Conversation
Sure! But that is only using r-release. So we'd know of regressions. No more, no less. Edit: Now turned on. |
At first it may be best to condition the use of the protect-unwind API with an explicit |
Which is not in the PR, correct? So why rev.dep check runs with it on unconditionally? |
Your revdeps should opt out automatically of the new API because they are compiled against R release. I am wondering whether it's best to also opt out of it by default on R 3.5 until |
We tend(ed) to release Rcpp every two months. By that timeline it will be January and March before R 3.5. |
Ok, so it seems best to condition so it is not automatically enabled when R 3.5 comes out. Does |
Because R code might run in C++ destructors
Reverse depends concluded, I just committed the log and summary. No compilation errors. A few new errors in testing from |
We're good. Those ten new ones were all spurious (two missing depends, one phantom gone under re-run, seven apparently due to testthat as they also fail under previous Rcpp tests). |
Great. Do you think we could get this merged for the next Rcpp release? Having it on CRAN will make it easier to start testing |
I think I'll just merge it as it, and we build from here. I trust the subsequent commits you made; I made let it run here once more with it. Looks like a job well done (though we'll only know for sure with R 3.5.*). And you of course get extra brownie points for embracing the Emacs-ish ChangeLog use. At long last someone does :) |
Maybe not for this PR, but what do you think about making Our
The intention of this code is to ensure that R longjmps are 'blocked' at this scope, so that longjmps never go 'up' the C++ stack. How does having the |
One potential problem is that
There is no interaction for errors and interrupts because the tryCatch prevents the R code from jumping in these cases. The stack is still unwound with the existing mechanism (even if the error was a normally returned condition and not the result of catching an actual error/interrupt jump). All other longjump causes are detected and a |
Fair enough. We might want to give that a shot later (in a separate PR).
Okay, awesome! Thanks for clarifying. |
By the way, if I'm not mistaken we could replace the This should improve performance a bit and give Edit: Facilitating long returns in this way would cause new kinds of leaks until the safe API is enabled. |
Unfortunately, I'm fairly sure this is code of that form out there already in R packages so we might not be able to make that change, unless we had a convincing example of commonly-written R/Rcpp code that does the wrong thing in the current scheme. |
Ok, so it seems that merging |
Fair enough. Perhaps we can just document for new users that |
Yup, probably best to wait until R 3.5 is out and the protected API enabled by default in Rcpp. |
(Mostly just nodding along...) |
Hi @lionel quick question: was some of the material in the PR activated for stack unwinding? With r-devel changing so much I had not pushed to win-builder in some time, and this evening I just got an error ending on
on 32 bit mode on r-devel. Full link is here for the usual time that win-builder keeps it. Could you take a look and see if it may be related? |
Only in the I'm not sure how the platform can impact the wrapping macros or exception catching. I am on vacations for one week and then I'll be busy preparing a webinar, so I won't have time to look into this further until January 25th. One easy way around this is to disable the test for now. It'd also be better to extract the test in its own file so the protection stuff is not enabled for the other tests in |
Ok, noted on the timing--bad luck, and my fault for not trying windows r-devel earlier, despite the current changes. As it is about release time for Rcpp, I will indeed just condition out the test. As it works on Linux, I will only run it there Don't send a PR just to isolate one test into another, that's not worth it. Enjoy the vacation... Once we work on re-activating this code with R 3.5.0 we can move tests into their file. PS I had done a bisection and also uploaded Rcpp from just before your patches, which passes. |
Turns out there may be more trouble. Your test is inactive, but I still have trouble with windows tests on either i386 or x86_64. Very, very weird. Still in the middle of it. |
I have sent a few instances of b52f690 to win-builder, will post results. |
I am currently doing that too. Sucketh big time because each iteration is 30+ minutes. The worst is that I have two complete sets of what is now HEAD which failed once and passed once. The same tarball ... |
More current thread also over there at #801. |
Not if you send with different versions ;-) And |
As I said over there, the same tarball got both a fail and a pass at two different points in time. What does |
I've sent five tarballs that are identical apart from the version number. Enough for a majority vote ;-) |
Good experimental design :) |
I am about done editing this locally. Let me test it once or twice here, then push the branch. I basically left all he added, but |
Ok, new branch is here and I would definitely appreciate another few sets of eyes. "Works here", submitted to win-builder and r-hub. |
Interesting. Maybe we should look at this together at the work week? In any case this doesn't explain the trouble caused by this branch because I'm pretty sure that Thanks for all your work sorting this out @eddelbuettel. |
No worries. Your patch meant to do the right thing, and we'll get there. I just had to pay extra today and yesterday because I don't usually run CI on Windows, and had not submitted "occassionally" as I usually do as R-devel changed to much of late. Lesson learned. |
shielding #789 behind a new #define to effectively disable it now
FWIW I have sent Rcpp 0.12.14 to win-builder and got a timeout while rebuilding the vignettes: https://win-builder.r-project.org/112Ax81s7Dib/00check.log Also R-hub times out in the tests with that same version. This seems to rule out this PR as the cause of undeterministic failures. |
No, that is precisely the issue. One of the vignettes runs all the unit tests and the fact that it doesn't come back absolutely is related to this issue. If you feel like it, try 0.12.13, or try what it is now in master and waiting at CRAN as 0.12.15. R-hub is likely a different issue indeed. |
If you care, this is what I got this morning before submitting this to CRAN as 0.12.15: r-devel
r-release
|
But the version I sent was anterior to this PR. Maybe the 4th version component causes too many tests to be run while building the vignette? |
Here are my logs from yesterday. Note that r-hub essentially always breaks. The key is that
|
Agreed. But we still need to figure out whether the PR really is the cause of the nondeterministic failures. Aren't you concerned that the failure also occurs with the previous CRAN release? |
Well, it doesn't. First entry:
PASS on r-devel and r-release is where we started, with a snapshot just after 0.12.14. I do not think that what you and I are doing right now is productive use of my time, or your vacation. We all had determined that the issue was with #789. You can fix it, or throw your arms in the air. But please do not make me re-visit every aspect now. We all missed that this comes up a lot on Windows, but also see @kevinushey above (or maybe in the #801 thread) stating that it also took his RStudio on OS X down though not each time. Maybe we should just wait til this stabilizes in R-devel. |
…sable it now" This reverts commit 81c8339.
…sable it now" This reverts commit 81c8339.
…sable it now" This reverts commit 81c8339.
…sable it now" This reverts commit 81c8339.
Use protected evaluation when compiling Rcpp against R 3.5 (see wch/r-source@c8cc608). This prevents leaks when R code jumps (caught condition, restart invokation, interrupt, return, error).
Add
Rcpp_fast_eval()
. UnlikeRcpp_eval()
, it doesn't wrap the code intryEval()
to avoid the catching overhead. It falls back toRcpp_eval()
when compiled against old versions of R so packages can use it without worrying about backward compatibility.Here are the differences between the new function and
Rcpp_eval()
:Rcpp::condition
. Instead they are rethrown asRcpp::internal::LongjumpException
as with all other longjump causes.Rf_eval()
rather than the R functionbase::eval()
. E.g. you can return from a frame environment on the R stack.These changes should be fully backward compatible. I have tested this branch on R oldrel, release and devel here: https://travis-ci.org/lionel-/Rcpp/builds/316466207 (without vignettes and with the binary package test disabled). I'm not sure how to adapt the current Travis config to use R devel.
I have checked this branch with dplyr (which calls into R a lot) on both R release and R devel. I have not run the reverse dependencies checks. Would it be possible to run those on your server Dirk?