From ripley at stats.ox.ac.uk  Thu May 12 19:49:54 2005
From: ripley at stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Thu May 12 19:50:02 2005
Subject: [Rd] segfault on large number of open brackets (PR#7859)
Message-ID: <20050512174954.23B69E17A@slim.kubism.ku.dk>

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.


On Thu, 12 May 2005 andy_liaw@merck.com wrote:

> I believe that's been fixed in R-2.1.0.  Please check.
>
> I got the same segfault with R-2.0.1 on SuSE Linux x86_64, but on both that
> machine and my WinXP latop, I get syntax error.  E.g.,
>
> R : Copyright 2005, The R Foundation for Statistical Computing
> Version 2.1.0 Patched (2005-05-12), ISBN 3-900051-07-0
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
>  Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for a HTML browser interface to help.
> Type 'q()' to quit R.
>
>> (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
> + (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
> Error: syntax error
>
> Andy
>
>
>> From: m.e.bruche@lse.ac.uk
>>
>> Full_Name: Max
>> Version: R 2.0.1 (2004-11-15)
>> OS: Gentoo Linux
>> Submission from: (NULL) (158.143.49.181)
>>
>>
>> I leaned on the "(" key by accident, and it looks as if R
>> segfaults on a large
>> number (88 or more in my case) open brackets:
>>
>> Script started on Thu May 12 15:18:04 2005
>> $ R
>>
>> R : Copyright 2004, The R Foundation for Statistical Computing
>> Version 2.0.1  (2004-11-15), ISBN 3-900051-07-0
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for a HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>>>
>> ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
>> ((((((((((((((((
>> (((((((((
>> + (
>> Segmentation fault
>> $ uname -a
>> Linux max 2.6.11-gentoo-r6 #2 Sat May 7 19:24:52 GMT 2005
>> i686 Intel(R)
>> Pentium(R) 4 CPU 2.40GHz GenuineIntel GNU/Linux
>> $ exit
>>
>> Script done on Thu May 12 15:18:16 2005
>>
>> Regards,
>>
>> Max
>>
>> R compiled with
>> gcc 3.3.5
>> glibc-2.3.4
>>
>> ______________________________________________
>> R-devel@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>>
>
> ______________________________________________
> R-devel@stat.math.ethz.ch 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


[Rd] segfault on large number of open brackets (PR#7859)
ripley@stats.ox.ac.uk