From ripley at stats.ox.ac.uk  Thu May 12 23:50:25 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu May 12 23:50:37 2005
Subject: [Rd] segfault on large number of open brackets (PR#7859)
In-Reply-To: <20050512174954.23B69E17A@slim.kubism.ku.dk>
References: <20050512174954.23B69E17A@slim.kubism.ku.dk>
Message-ID: <Pine.LNX.4.61.0505122248370.13448@gannet.stats>

On Thu, 12 May 2005 ripley@stats.ox.ac.uk wrote:

> I suspect that is coincidence, as I can see no source change that would
> account for it.
>
> 2.0.1 and R-devel work for me and 2.1.0 segfaults with
>
> 999         KeepSource = *LOGICAL(GetOption(install("keep.source"), R_NilValue));
> (gdb) bt
> #0  0x080ca229 in ParseInit () at gram.y:999
> #1  0x080cb305 in token () at gram.y:1530
>
> I am not sure that is right, but I am pretty sure that
>
> static char	contextstack[50], *contextp;
>
> just above is an unchecked nesting limit, as in
>
> static void IfPush(void)
> {
>     if (*contextp==LBRACE ||
> 	*contextp=='['    ||
> 	*contextp=='('    ||
> 	*contextp == 'i')
> 	    *++contextp = 'i';
> }
>
> However, although I thought this was the problem, it seems only to apply
> to nested if()s.  So I do not currently have a solution.

I was almost right, just a different instance of *++contextp.

Fixed in R-patched, to give

> (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
Error: contextstack overflow


-- 
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] segfault on large number of open brackets (PR#7859)
Prof Brian Ripley