From ripley at stats.ox.ac.uk  Thu Nov 24 08:00:37 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 24 Nov 2005 07:00:37 +0000 (GMT)
Subject: [Rd] Infinite recursion in S3 methods crashes R on windows
 (related to PR#8203?)
In-Reply-To: <5934ae570511231353s2e01cb2fh6996b0b977de21b4@mail.gmail.com>
References: <5934ae570511231353s2e01cb2fh6996b0b977de21b4@mail.gmail.com>
Message-ID: <Pine.LNX.4.61.0511240650400.31387@gannet.stats>

On Thu, 24 Nov 2005, Rich FitzJohn wrote:

> Hi,
>
> Infinite recursion in S3 methods seem to crash R on Windows 2000 (R
> terminating with the ("Rgui.exe has generated errors...") message,
> rather than throwing an error.  This happens with both Rgui and Rterm.
>
> The following toy example triggers this:
> myf <- function(x, ...)
>  UseMethod("myf")
>
> myf.default <- function(x, ...)
>  myf(x)
>
> myf(1)
> ...R crashes...
>
> Which I would expect to terminate with the usual "evaluation nested
> too deeply: infinite recursion" or protect stack overflow message.
>
> This may be related to the reported bug 8203 - apologies if this has
> been fixed.  I couldn't find specific mention of this in the NEWS
> file.

PR#8203 is attributed to C-stack overflow, and there is a prominent 
message (quoted below) in NEWS.

> This does not happen on R 2.1.0 on Windows 2000 (same machine), or on
> R 2.2.0 on Linux.  R/Machine version below.

What is happening is that the Windows C stack is being overflowed before 
the evaluation limit is reached, and what happens thereafter is random.
So it would probably also crash in 2.1.0 eventually.

This has already been fixed, and the R-patched NEWS file says

USER-VISIBLE CHANGES

     o   options("expressions") has been reduced to 1000: the limit
         of 5000 introduced in 2.1.0 was liable to give crashes from C
         stack overflow.

and the Windows CHANGES file says

The maximum C stack size for RGui.exe and Rterm.exe has been increased
to 10Mb (from 2Mb); this is comparable with the default on Linux systems
and may allow some larger programs to run without crashes.


-- 
Brian D. Ripley,                  ripley at 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] Infinite recursion in S3 methods crashes R on windows (related to PR#8203?)
Prof Brian Ripley