-
-
Notifications
You must be signed in to change notification settings - Fork 219
Remove unsafe usage of Rf_eval (close #498) #523
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
@@ -54,7 +54,7 @@ inline SEXP Rcpp_eval(SEXP expr, SEXP env) { | |||
SET_TAG(CDDR(CDR(call)), ::Rf_install("interrupt")); | |||
|
|||
// execute the call | |||
Shield<SEXP> res(::Rf_eval(call, R_GlobalEnv)); | |||
Shield<SEXP> res(::Rf_eval(call, env)); |
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.
Why the switch from R_GlobalEnv
to env
here but not on line 69?
Shield<SEXP> conditionMessage(::Rf_eval(conditionMessageCall, R_GlobalEnv));
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.
Actually this switch is not necessary, since we already have the env
from evalq
. I involve this when trying to simplify Rcpp_eval
. I will update.
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.
The evalq
call itself might be unneeded, really -- we could probably omit constructing of the evalq
bit and just evaluate the tryCatch
expression in env
.
We want to ensure that expr
is evaluated in env
, but the other usages likely want to just be evaluated in the global environment.
Thank you -- nice work. Is that "all of them" or just the ones you thought we could safely change? I seem to recall @kevinushey mentioning that maybe some needed to remain or something to that extend. Or am I misremembering? Anybody to second the thumbs-up? |
Looks great, thanks! @eddelbuettel I was thinking that the https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/exceptions.h#L197 probably don't want to be touched, as that's code that will get called in our try-catch macros, e.g. at https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/macros/macros.h#L37-L57 and so This PR doesn't touch those usages so I think that's okay. |
Thank you both -- in it goes! And I resolve to do a full rev.dep check tomorrow. Worst case we revert. |
Just for the record it passed the rev.dep with flying colours as expected. |
cf discussion in #523 commit log on GH
@kevinushey