[Rd] Bug in parse(text = <long polynom>) (PR#7022)

maechler at stat.math.ethz.ch maechler at stat.math.ethz.ch
Fri Jun 25 09:19:40 CEST 2004


Merci beaucoup, Jean,
for the bug report -- which I'm no "completeing" to R-bugs

>>>>> "Jean" == Jean Coursol <coursol at 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.



More information about the R-devel mailing list