-
-
Notifications
You must be signed in to change notification settings - Fork 219
Reset errors after evaluation (closes #312) #313
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
Conversation
Looks good to me. @eddelbuettel ? |
Bit fried and tired after two days of Rcpp teaching here in Zuerich ... We can keep it in a branch, or merge it as is, or maybe tests along the to-be-tested String change. I should have some time for all of this over the next few days. Or so I hope ... But feel free to take the lead on this and don't wait on me if you feel it's ready. |
Thanks for jumping on this @kevinushey. This case fails, I'd expect it to be silent but I get an error: exec(function() {
try(silent = T, exec(function() {
options(warn = 2)
warning("hi")
}))
}) |
Thanks @jcheng5. This is another manifestation of the error issue before: the warning |
I have a candidate fix for the warning bit -- ensure that Similarly, I wonder if both |
I think we are basically forced to attach calling handlers only at the top level. This is what the warning recorders see in that call (minus the most recent commit on this PR):
So, both recorders see the same warning message, and so both attempt to forward the same warning. The error is then seen when the warning is forwarded outside of the EDIT: I think I may understand what's happening. When we attempt to print out captured warnings, we don't evaluate it in a top-level context -- ie, call In other words, the warning gets forwarded by each handler from the deepest level of execution all the way to the top level, where it is then emitted (potentially bypassing other calling handlers that may influence how the warning should have been printed). I do not yet know what the best way of handling this is -- I think each evaluation effectively needs to emit its warnings, but outside the context of the That said -- I still do not have a handle on what the best fix here is. It seems like we do want handlers attached to each |
} | ||
|
||
inline SEXP Rcpp_eval(SEXP expr_, SEXP env) { | ||
|
||
// record call depth (only top-level attaches recorders) | ||
static int depth; |
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.
this should be initialized to zero I think
@kevinushey this looks ready for merge to me. Any objection to doing so now? |
I'd be happy to do so and try to turn on the rev dep run a little later. |
Actually, I think there might be one more subtlety to address. Since the static depth counter is within an inline function I'm thinking that each package which uses Rcpp will get it's own depth counter (I could be wrong though) and we still may end up with the same issue when multiple packages which include Rcpp try to play together (likely in the case of httpuv as it's callbacks often invoke arbitrary other code in packages used within shiny applications). I'm I'm right then we need a static depth counter which is incremented and decremented using functions exposed from libRcpp.so (sort of like we do with the RNG scope counter now). @kevinushey What do you think? |
@jjallaire I think you're exactly right. I think this PR should be split into two pieces:
I am pretty confident that (1) is the correct change there; (2) is going to be quite tricky to get right. So I'll strip out the latest commit and then I think we can merge that (so that errors are properly handled); we can then handle (2) in a separate PR. |
2a0e615
to
d4cbbcc
Compare
I'm going to merge this now; we can deal with the other issues in a separate PR. |
Reset errors after evaluation (closes #312)
Sounds good. Dirk and I had a discussion regarding whether we should make It's obviously cleaner to insist on the integrity of version-synced headers Let's settle this over email / PR over the next few days. On Sun, Jun 28, 2015 at 5:10 PM, Kevin Ushey notifications@github.com
|
What I'm thinking we would do is to modify this code for calling the https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/routines.h#L77-L81 To check for whether it actually got a function pointer or not. If it I realize that this isn't ideal, but breaking everyone all of sudden also I would only advocate for doing this if there were no other changes e.g. On Sun, Jun 28, 2015 at 11:30 PM, JJ Allaire jj.allaire@gmail.com wrote:
|
This fixes a bug where nested calls to Rcpp functions (through
Rcpp_eval
) would end up seeing the same error stack, and hence all would report the same error.