Re: [Rd] R windows crash (PR#9426)

From: <ripley_at_stats.ox.ac.uk>
Date: Thu 21 Dec 2006 - 08:22:54 GMT


The problem is rather that 'aa' *is* found: default arguments are looked for within the body of the function, and so the calculation of 'aa' is recursive. Consider the simpler case

> testfun <- function(aa=aa) {aa <- c(aa); aa}
> testfun()

Error in testfun() : recursive default argument reference

On Linux I got

> testfun() #R then exits.
Error: segfault from C stack overflow

Now C stack overflows are instantly fatal on Windows and cannot be caught there. However, using Linux enabled me to locate the loop in a debugger, and it is recursion in isMissing to which I have added a stack check.

The remedy is I hope obvious: 'don't do that'.

Adding these checks do have a small but measurable performance cost so we have been conservative in adding them.

On Thu, 21 Dec 2006, robert.denham@nrm.qld.gov.au wrote:

> Full_Name: Robert Denham
> Version: R-2.4.1
> OS: Windows Xp
> Submission from: (NULL) (61.88.57.1)
>
>
> R gui exits without warning when I run a function which has an argument with a
> default that is not found.
>
> This was a result of an error in a function I wrote, but I thought that it
> should exit more gracefully than it does. Here is an example:
>
>
> testfun <- function(aa=aa) {
> aa <- lm(y~x,data=aa)
> return(aa)
> }
>
> testfun() #R then exits.
>
> Note that
>
> testfun <- function(aa=bb) {
> aa <- lm(y~x,data=aa)
> return(aa)
> }
>
> works as it should, giving "object bb not found".
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu Dec 21 19:25:18 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 21 Dec 2006 - 08:31:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.