maechler@stat.math.ethz.ch
2004-Jun-25 09:19 UTC
[Rd] Bug in parse(text = <long polynom>) (PR#7022)
Merci beaucoup, Jean, for the bug report -- which I'm no "completeing" to R-bugs>>>>> "Jean" == Jean Coursol <coursol@cristal.math.u-psud.fr> >>>>> on Thu, 24 Jun 2004 15:22:37 +0200 (CEST) writes:Jean> I was exploring the polynom library with students: <and found a segmentation fault from parsing a long expression> The following is reproducible also with the current version of R 1.9.1 [on RHEL Linux] horner <- function(p) { a <- as.character(rev(unclass(p))) h <- a[1] while (length(a <- a[-1]) > 0) { h <- paste("x*(", h, ")", sep = "") if (a[1] != 0) h <- paste(a[1], " + ", h, sep = "") } h } library(polynom) x <- polynomial() z <- (1+x)^100 zh <- horner(z) nchar(zh) ## [1] 2404 parse(text = zh) # => Segmentation fault ## where Jean wrote '(it ran one time !!!)' ## and it happens the first time for me.
maechler@stat.math.ethz.ch writes:> Merci beaucoup, Jean, > for the bug report -- which I'm no "completeing" to R-bugsBut you're still requiring library(polynom) for triggering the bug. If we are to be sure that it is not a bug in that package but a bug in R, you need to include the definition of at least polynomial() with the instructions to reproduce the effect... [snip]> library(polynom) > > x <- polynomial() > z <- (1+x)^100 > zh <- horner(z)-- 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
ripley@stats.ox.ac.uk
2004-Jun-25 10:09 UTC
[Rd] Bug in parse(text = <long polynom>) (PR#7022)
On 25 Jun 2004, Peter Dalgaard wrote:> maechler@stat.math.ethz.ch writes: > > > Merci beaucoup, Jean, > > for the bug report -- which I'm no "completeing" to R-bugs > > But you're still requiring library(polynom) for triggering the bug. If > we are to be sure that it is not a bug in that packageThere seems to be in that it is not using the R code from `S Programming' p.95, according to the original report.> but a bug in R, > you need to include the definition of at least polynomial() with the > instructions to reproduce the effect... > > [snip] > > library(polynom) > > > > x <- polynomial() > > z <- (1+x)^100 > > zh <- horner(z)Hmm, horner is not in the package! It is a function internal to as.function.polynomial. as.function(z) segfaults at #0 R_TextBufferGetc (txtb=0xffda00) at /users/ripley/R/cvs/R-devel/src/main/iosupport.c:232 #1 0x080c7623 in text_getc () at ./gram.y:1011 #2 0x080c6eed in xxgetc () at ./gram.y:291 #3 0x080c7bc5 in token () at ./gram.y:1496 #4 0x080c85c5 in Rf_yylex () at ./gram.y:1894 #5 0x080c8bef in Rf_yyparse () at /usr/share/bison/bison.simple:573 #6 0x080c997e in R_Parse1 (status=0xbfffda58) at ./gram.y:941 #7 0x080c9aad in R_Parse (n=-1, status=0xbfffda58) at ./gram.y:1076 #8 0x080c9c1e in R_ParseVector (text=0xffffffff, n=-1, status=0xffffffff) at ./gram.y:1153 #9 0x0813c3d9 in do_parse (call=0x8500c00, op=0xffffffff, args=0x84fb898, env=0x8ed385c) at /users/ripley/R/cvs/R-devel/src/main/source.c:68 so that's definitely a bug in R. It is being asked to parse a very long line and a highly-nested expression. I suspect the latter is the problem. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
maechler@stat.math.ethz.ch
2004-Jun-25 10:19 UTC
[Rd] Bug in parse(text = <long polynom>) (PR#7022)
>>>>> "PD" == Peter Dalgaard <p.dalgaard@biostat.ku.dk> >>>>> on 25 Jun 2004 09:32:48 +0200 writes:PD> maechler@stat.math.ethz.ch writes: >> Merci beaucoup, Jean, for the bug report -- which I'm no >> "completeing" to R-bugs PD> But you're still requiring library(polynom) for PD> triggering the bug. If we are to be sure that it is not PD> a bug in that package but a bug in R, you need to PD> include the definition of at least polynomial() with the PD> instructions to reproduce the effect... well, try this (without package polynom):> parse(text="1 + x*(100 + x*(4950 + x*(161700 + x*(3921225 + x*(75287520 + x*(1192052400 + x*(16007560800 + x*(186087894300 + x*(1902231808400 + x*(17310309456440 + x*(141629804643600 + x*(1050421051106700 + x*(7110542499799200 + x*(44186942677323608 + x*(253338471349988672 + x*(1345860629046814720 + x*(6650134872937201664 + x*(30664510802988208128 + x*(1.32341572939212e+20 + x*(5.3598337040381e+20 + x*(2.04184141106213e+21 + x*(7.33206688517765e+21 + x*(2.48652703062547e+22 + x*(7.97760755659004e+22 + x*(2.42519269720337e+23 + x*(6.99574816500972e+23 + x*(1.91735320078044e+24 + x*(4.99881370203473e+24 + x*(1.24108478119483e+25 + x*(2.93723398216109e+25 + x*(6.63246383068634e+25 + x*(1.43012501349174e+26 + x*(2.94692427022541e+26 + x*(5.8071742972089e+26 + x*(1.09506715318796e+27 + x*(1.97720458214493e+27 + x*(3.42002954749394e+27 + x*(5.67004898663469e+27 + x*(9.01392403003463e+27 + x*(1.37462341458028e+28 + x*(2.01164402133700e+28 + x*(2.82588088711626e+28 + x*(3.81165328959867e+28 + x*(4.93782357970737e+28 + x*(6.14484712141362e+28 + x*(7.3470998190815e+28 + x*(8.4413487283064e+28 + x*(9.320655887505e+28 + x*(9.8913082887808e+28 + x*(1.00891344545564e+29 + x*(9.8913082887808e+28 + x*(9.320655887505e+28 + x*(8.4413487283064e+28 + x*(7.3470998190815e+28 + x*(6.14484712141362e+28 + x*(4.93782357970737e+28 + x*(3.81165328959867e+28 + x*(2.82588088711626e+28 + x*(2.01164402133700e+28 + x*(1.37462341458028e+28 + x*(9.01392403003463e+27 + x*(5.67004898663469e+27 + x*(3.42002954749394e+27 + x*(1.97720458214493e+27 + x*(1.09506715318796e+27 + x*(5.8071742972089e+26 + x*(2.94692427022541e+26 + x*(1.43012501349174e+26 + x*(6.63246383068634e+25 + x*(2.93723398216109e+25 + x*(1.24108478119483e+25 + x*(4.99881370203473e+24 + x*(1.91735320078044e+24 + x*(6.99574816500972e+23 + x*(2.42519269720337e+23 + x*(7.97760755659004e+22 + x*(2.48652703062547e+22 + x*(7.33206688517765e+21 + x*(2.04184141106213e+21 + x*(5.3598337040381e+20 + x*(1.32341572939212e+20 + x*(30664510802988208128 + x*(6650134872937201664 + x*(1345860629046814720 + x*(253338471349988672 + x*(44186942677323608 + x*(7110542499799200 + x*(1050421051106700 + x*(141629804643600 + x*(17310309456440 + x*(1902231808400 + x*(186087894300 + x*(16007560800 + x*(1192052400 + x*(75287520 + x*(3921225 + x*(161700 + x*(4950 + x*(100 + x*(1))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))")
maechler@stat.math.ethz.ch
2004-Jun-25 10:42 UTC
[Rd] Bug in parse(text = <long polynom>) (PR#7022)
>>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch> >>>>> on Fri, 25 Jun 2004 10:19:19 +0200 writes:>>>>> "PD" == Peter Dalgaard <p.dalgaard@biostat.ku.dk> >>>>> on 25 Jun 2004 09:32:48 +0200 writes:PD> But you're still requiring library(polynom) for PD> triggering the bug. If we are to be sure that it is not PD> a bug in that package but a bug in R, you need to PD> include the definition of at least polynomial() with the PD> instructions to reproduce the effect... MM> well, try this (without package polynom): >> parse(text="1 + x*(100 + x*(4950 + x*(161700 + x*(3921225 .... and then I had the full length 2404 string which---I had "known in advance" (Murphy's law)--- has been thrown up before it got back to R-devel, actually by my mailer already. Now this should be easier to pass through: tt <- tempfile() download.file("ftp://ftp.stat.math.ethz.ch/U/maechler/R/longpoly.rda", tt) load(tt) zh # look at the long "polygon string" parse(text=zh) ## seg.fault -- Martin