From ripley at stats.ox.ac.uk  Thu Jan 29 12:16:01 2004
From: ripley at stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Thu Jan 29 12:34:56 2004
Subject: [Rd] unstability when using isoreg() function (PR#6494)
Message-ID: <20040129111601.A2E65102B3@slim.kubism.ku.dk>

iKnots was allocated one element too short.  This only overruns if the 
sequence is monotone, as happens here for set.seed(2), N=3.  Fixed in 
R-devel.

The line 39 in isoreg.c needs to be

    SET_VECTOR_ELT(ans, 3, iKnots= allocVector(INTSXP, n));


Duncan was trying to give a reproducible example, Petr, as we do ask you 
to do in the FAQ.

On Thu, 29 Jan 2004 dmurdoch@pair.com wrote:

> On Wed, 28 Jan 2004 17:31:27 +0100 (CET), you wrote:
> 
> >Full_Name: Petr Klasterecky
> >Version: 1.8.1
> >OS: Windows XP, Linux
> >Submission from: (NULL) (195.113.27.212)
> >
> >
> >The isoreg() function causes R to crash when called repeatedly. Consider the
> >following simple script:
> >
> >{
> >library(modreg)
> >N <- 10
> >x <- rnorm(N)
> >print("Original x values:")
> >print(x)
> >for(n in (1:N)){print(y <- isoreg(x[1:n])$yf)}
> >} 
> 
> I get the crash reproducibly in r-devel after I put "set.seed(2)"
> ahead of the sample code above.  (Of course, r-devel doesn't need the
> library(modreg), but that doesn't affect the bug.)  Other seeds and
> the code works without error.
> 
> I tried tracing into R_isoreg to try to spot the problem, but the
> error occurs after it returns.  It has all the symptoms of some code
> writing outside allocated bounds, but I couldn't see where that
> happened.
> 
> Duncan Murdoch
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
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


[Rd] unstability when using isoreg() function (PR#6494)
ripley@stats.ox.ac.uk