Romain Francois
2011-Jan-11 19:33 UTC
[Rd] as.environment.list provides inconsistent results under torture
Hello, Using R-devel (rev 53950), I get inconsistent results with as.environment( VECSXP ) when gctorture is on. Consider: a <- list( aa = rnorm, bb = runif ) gctorture(TRUE) as.environment( a ) The last line sometimes produces the correct environment, but sometimes I get errors. Here are the three situations: # good > as.environment( a ) <environment: 0x100b1c978> # not good > as.environment( a ) Erreur dans length(x) : 'x' est manquant # not good either > as.environment( a ) Erreur dans list(NULL, list(aa = function (n, mean = 0, sd = 1) : correspondance partielle de cha?nes de caract?res incorrecte Is it because the call made by lang4 is not protected while evaluated in this line : case VECSXP: { /* implement as.environment.list() {isObject(.) is false for a list} */ return(eval(lang4(install("list2env"), arg, /*envir = */R_NilValue, /* parent = */R_EmptyEnv), rho)); } (BTW, this was detected in a looooooooong Rcpp-devel thread. See http://comments.gmane.org/gmane.comp.lang.r.rcpp/1336) Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/fT2rZM : highlight 0.2-5 |- http://bit.ly/gpCSpH : Evolution of Rcpp code size `- http://bit.ly/hovakS : RcppGSL initial release
Simon Urbanek
2011-Jan-11 22:15 UTC
[Rd] as.environment.list provides inconsistent results under torture
Interesting, I'd argue that the bug is in eval() not protecting its arguments since the usual convention is for functions to protect its arguments... On Jan 11, 2011, at 2:33 PM, Romain Francois wrote:> Hello, > > Using R-devel (rev 53950), I get inconsistent results with as.environment( VECSXP ) when gctorture is on. > > Consider: > > a <- list( aa = rnorm, bb = runif ) > gctorture(TRUE) > as.environment( a ) > > The last line sometimes produces the correct environment, but sometimes I get errors. Here are the three situations: > > # good > > as.environment( a ) > <environment: 0x100b1c978> > > # not good > > as.environment( a ) > Erreur dans length(x) : 'x' est manquant > > # not good either > > as.environment( a ) > Erreur dans list(NULL, list(aa = function (n, mean = 0, sd = 1) : > correspondance partielle de cha?nes de caract?res incorrecte > > > Is it because the call made by lang4 is not protected while evaluated in this line : > > case VECSXP: { > /* implement as.environment.list() {isObject(.) is false for a list} */ > return(eval(lang4(install("list2env"), arg, > /*envir = */R_NilValue, /* parent = */R_EmptyEnv), > rho)); > } > > > (BTW, this was detected in a looooooooong Rcpp-devel thread. See http://comments.gmane.org/gmane.comp.lang.r.rcpp/1336) > > Romain > > -- > Romain Francois > Professional R Enthusiast > +33(0) 6 28 91 30 30 > http://romainfrancois.blog.free.fr > |- http://bit.ly/fT2rZM : highlight 0.2-5 > |- http://bit.ly/gpCSpH : Evolution of Rcpp code size > `- http://bit.ly/hovakS : RcppGSL initial release > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >