rmh@surfer.sbm.temple.edu
2001-Dec-11 22:32 UTC
[Rd] crash bug in get("function.name")() (PR#1211)
R : Copyright 2001, The R Development Core Team Version 1.3.1 (2001-08-31)> tmp <- factor(1:3) > get("print.factor")(tmp)[1] 1 2 3 Levels: 1 2 3> print.a <- function(x,...) {+ print("this is a") + NextMethod("print", x, quote = FALSE, right = TRUE, ...) + }> > get("print.a")function(x,...) { print("this is a") NextMethod("print", x, quote = FALSE, right = TRUE, ...) }> print.a(tmp)[1] "this is a" [1] 1 2 3 Levels: 1 2 3> get("print.a")(tmp)[1] "this is a" Process R exited abnormally with code 5 at Tue Dec 11 16:18:17 2001 ---- I am using the windows version rw1031 I also tried on rw1030. rw1030 gives a different code Process R exited abnormally with code 255 at Tue Dec 11 17:31:06 2001 Rich -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
rmh@surfer.sbm.temple.edu wrote:> > R : Copyright 2001, The R Development Core Team > Version 1.3.1 (2001-08-31) > > > tmp <- factor(1:3) > > get("print.factor")(tmp) > [1] 1 2 3 > Levels: 1 2 3 > > print.a <- function(x,...) { > + print("this is a") > + NextMethod("print", x, quote = FALSE, right = TRUE, ...) > + } > > > > get("print.a") > function(x,...) { > print("this is a") > NextMethod("print", x, quote = FALSE, right = TRUE, ...) > } > > print.a(tmp) > [1] "this is a" > [1] 1 2 3 > Levels: 1 2 3 > > get("print.a")(tmp) > [1] "this is a" > > Process R exited abnormally with code 5 at Tue Dec 11 16:18:17 2001 > > ---- > > I am using the windows version rw1031 > > I also tried on rw1030. rw1030 gives a different code > Process R exited abnormally with code 255 at Tue Dec 11 17:31:06 2001With an existing workspace the same happens with R-1.4.0 (unstable) on WinNT4. Also in R-1.4.0 (unstable) the last lines of your example, if started without an existing workspace, results in:> print.a(tmp)[1] "this is a" [1] 1 2 3 Levels: 1 2 3> get("print.a")(tmp)[1] "this is a" Error in get("print.a")(tmp) : function is not a closure> get("print.a")Error: attempt to apply non-function> get#### Now a crash! Uwe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter, your explanation looks right to me, and is certainly consistent with the crash behavior of get("print.a") The R-1.4.0 error message is a good check. I would think the explanation should prevent the other example from working as well. But this one works get("print.factor")(tmp) exactly as expected. Both of these examples work correctly in S-Plus 4.5 Rich -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
p.dalgaard@biostat.ku.dk
2001-Dec-12 13:18 UTC
[Rd] crash bug in get("function.name")() (PR#1211)
Rich Heiberger <rmh@surfer.sbm.temple.edu> writes:> Peter, your explanation looks right to me, and is certainly consistent > with the crash behavior of > get("print.a") > The R-1.4.0 error message is a good check. > > I would think the explanation should prevent the other example from > working as well. But this one works > get("print.factor")(tmp) > exactly as expected. > > Both of these examples work correctly in S-Plus 4.5(S-PLUS 3.4 too) There's no NextMethod in print.factor, but I was wrong on the other example: It has NextMethod("print",....) with an explicit generic, so I don't think it should go near the CAR(call) bit at all. I'll take a closer look, but there's also a few other nasty bugs nagging us at the moment, and this looks like it could require surgery to do_nextmethod with some risk of complications. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
luke@nokomis.stat.umn.edu
2001-Dec-12 15:52 UTC
[Rd] crash bug in get("function.name")() (PR#1211)
I don't think I'll get to look at this cerefully today, but here is just a thought: My recollection is that NextMethod needs to be called only from within a usemethod dispatch because the dispatch needs to set up stuff in the environment that NextMethod needs. If you do print.a <- function(...) NextMethod() and then call print.a directly then the stuff NextMethod needs isn't set up, so NextMethod can't do anything useful. I think the do_nextmethod tries to detect this and raise an error, but for some reason it isn't detecting the problem here. luke On Wed, Dec 12, 2001 at 02:11:07PM +0100, Peter Dalgaard BSA wrote:> Rich Heiberger <rmh@surfer.sbm.temple.edu> writes: > > > Peter, your explanation looks right to me, and is certainly consistent > > with the crash behavior of > > get("print.a") > > The R-1.4.0 error message is a good check. > > > > I would think the explanation should prevent the other example from > > working as well. But this one works > > get("print.factor")(tmp) > > exactly as expected. > > > > Both of these examples work correctly in S-Plus 4.5 > > (S-PLUS 3.4 too) > > There's no NextMethod in print.factor, but I was wrong on the other > example: It has NextMethod("print",....) with an explicit generic, so > I don't think it should go near the CAR(call) bit at all. > > I'll take a closer look, but there's also a few other nasty bugs > nagging us at the moment, and this looks like it could require surgery > to do_nextmethod with some risk of complications. > > -- > O__ ---- Peter Dalgaard Blegdamsvej 3 > c/ /'_ --- Dept. of Biostatistics 2200 Cph. N > (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 > ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Luke Tierney University of Minnesota Phone: 612-625-7843 School of Statistics Fax: 612-624-8868 313 Ford Hall, 224 Church St. S.E. email: luke@stat.umn.edu Minneapolis, MN 55455 USA WWW: http://www.stat.umn.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._