-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
When calling a Function, destructors do not execute when quitting from debugger #754
Comments
I am experimenting with a new approach for handling longjumps. You can find it at lionel-/r-source@62d1d81. It does not require wrapping the R code in a The idea is to declare a pair of forwarded and forwarding contexts.
Effectively the longjump is interrupted between the forwarding and forwarded frame which leaves Rcpp free to unwind the stack properly. I still need to test this more thoroughly and double check everything but the preliminary tests work well. |
Let's get Rcpp 0.12.13 out of the way in a few days, and then we have plenty of time to test this. Much appreciate you looking into this. |
I recall we switched to withCallingHandlers(
rcpp_warning(),
warning = function(w) {
print("Hello from warning handler!")
}
) or: tryCatch(
rcpp_warning(),
warning = function(w) {
print("Hello from warning handler!")
}
) where |
Yes it works well. I still need to think through what happens when another longjump occurs between the forwarded and forwarding frames (these may need better names). |
Ok the patch is ready I think, I'm going to send it to Luke and Tomas: https://github.com/lionel-/r-source/pull/3 Here is how Rcpp would use the new facilities: master...lionel-:impl-unwind I wonder if |
Cool!!!
We'd probably need to conditionally compile this codepath so that it works
in newer versions of R that have the patch but remains compatible with
older versions. Hopefully there is an #ifdef check suitable for this
available.
…On Thu, Sep 28, 2017 at 10:39 AM, Lionel Henry ***@***.***> wrote:
Ok the patch is ready I think, I'm going to send it to Luke and Tomas:
lionel-/r-source#3 <https://github.com/lionel-/r-source/pull/3>
Here is how Rcpp would use the new facilities:
master...lionel-:impl-unwind
<master...lionel-:impl-unwind>
I wonder if LongjumpException should be in the Rcpp namespace rather than
in Rcpp::internal. This way Rcpp users could exclude the longjump
exception from catch-all statements, since it really needs to be thrown all
the way to the wrapper macros.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#754 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGXx19oONEB0clFi5jsxERcpEDMvgYjks5sm6--gaJpZM4PefNV>
.
|
Yes we can use this: #include <Rversion.h>
#if (defined(R_VERSION) && R_VERSION > R_Version(3, 5, 0))
We can make |
You rock! We just got Rcpp 0.12.13 onto CRAN, always takes a few days from our end and then Uwe was traveling earlier in the week too -- so I was about to poke you. Now, and I'm just out of meetings so apologies if you detail this somewhere: how could we / would we use this before R 3.5.0 is out? Ie can R-release and Rcpp access this? |
If the patch is accepted we can integrate it with Rcpp with the conditional codepaths as suggested by JJ. Then the new stack-unwinding system will be enabled on R-devel distributions, including on Travis. We'll first have to see if Luke finds the approach sound and accepts the patch. Fingers crossed! |
Could |
It could but I was afraid some code might be relying on Rcpp converting R errors to C++ exceptions. It seemed safer to preserve the current behaviour and let packages progressively move to the faster eval function if they need the performance. |
Luke said he's not happy with this approach and that he and Tomas will try to come up with something for the next release if they have time. |
Luke committed the unwind API a few days ago! I'm working on a PR to use it in Rcpp. |
This issue is stale (365 days without activity) and will be closed in 31 days unless new activity is seen. Please feel free to re-open it is still a concern, possibly with additional data. |
This is a follow-up to #753. @jjallaire said this might not be fixable but I'm filing it here for future reference.
Destructors do not execute when the C++ code calls a Function, the function goes into the R debugger console, and the user quits with
Q
.The text was updated successfully, but these errors were encountered: