From murdoch at stats.uwo.ca  Thu Jul 16 02:45:15 2009
From: murdoch at stats.uwo.ca (murdoch at stats.uwo.ca)
Date: Thu, 16 Jul 2009 02:45:15 +0200 (CEST)
Subject: [Rd] Resizing a named vector crashes R with
	gctorture(TRUE)	(PR#13837)
Message-ID: <20090716004516.0A505282BE84@mail.pubhealth.ku.dk>

On 15/07/2009 8:30 PM, murdoch at stats.uwo.ca wrote:
> On 15/07/2009 8:08 PM, Herv? Pag?s wrote:
>> Hi,
>>
>>    > x <- c(a=10, b=20)
>>    > length(x) <- 1
>>    > x
>>     a
>>    10
>>
>> But with gctorture turned on, I get:
>>
>>    > gctorture(TRUE)
>>    > x <- c(a=10, b=20)
>>    > length(x) <- 1
>>    > x
>>      a
>>    "a"   <---- ???
>>
>>    > x <- c(a=10, b=20)
>>    > length(x) <- 3
>>
>>     *** caught segfault ***
>>    address (nil), cause 'unknown'
>>
>>    Possible actions:
>>    1: abort (with core dump, if enabled)
>>    2: normal R exit
>>    3: exit R without saving workspace
>>    4: exit R saving workspace
>>
>> This seems to have been around for a while (I get this with R 2.10,
>> 2.9 and 2.8). Note that I don't get this with an unnamed vector.
>>
>> This problem affects the methods package. I found it while
>> troubleshooting the "Protection stack overflow" I reported earlier
>> (see https://stat.ethz.ch/pipermail/r-devel/2009-July/054030.html)
>> but I can't tell yet whether the 2 issues are related or not.
> 
> That's clearly a bug (reproducible in today's R-devel build); I've cc'd 
> this reply to r-bugs.  I'll take a look and see if I can track it down.

That's got to be the easiest low-level bug I've worked on in a while. 
Just a missing PROTECT.  Now fixed, about to be committed to R-devel.

Duncan Murdoch

> 
>> It would be nice to see some reaction from the R developers
>> about these issues. Thanks in advance!
> 
> You should post them as bug reports if they are as clearly bugs as this 
> one; otherwise they can easily get lost in the noise.  I'm not going to 
> offer to look into the other one; I don't know the insides of the 
> methods package.
> 
> Duncan Murdoch
> 
>> H.
>>
>>
>> hpages at fhcrc.org wrote:
>>> Hi,
>>>
>>>   > gctorture(TRUE)
>>>   > setGeneric("foo", function(x, y) standardGeneric("foo"))
>>>   [1] "foo"
>>>   > setMethod("foo", c("ANY", "ANY"),
>>>   +   function(x, y) cat("calling foo,ANY,ANY method\n")
>>>   + )
>>>   Error: protect(): protection stack overflow
>>>
>>> Sorry this is something I already reported one week ago here
>>>   https://stat.ethz.ch/pipermail/r-devel/2009-July/053973.html
>>> but I just had a 2nd look at it and realized that the problem
>>> can in fact be reproduced out of the .onLoad() hook. So I'm
>>> reporting it again with a different subject.
>>>
>>> See my sessionInfo() below. Thanks!
>>> H.
>>>
>>>
>>>> sessionInfo()
>>> R version 2.10.0 Under development (unstable) (2009-06-26 r48837)
>>> x86_64-unknown-linux-gnu
>>>
>>> locale:
>>>  [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C
>>>  [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8
>>>  [5] LC_MONETARY=C              LC_MESSAGES=en_CA.UTF-8
>>>  [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C
>>>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
>>> [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Resizing a named vector crashes R with gctorture(TRUE) (PR#13837)
murdoch at stats.uwo.ca