[Rd] split() bug? Inconsistent Windows/Linux behavior.

Duncan Murdoch murdoch.duncan at gmail.com
Wed May 5 02:08:47 CEST 2010


On 04/05/2010 6:45 PM, Matt Shotwell wrote:
> This is odd, I think it may have something to do with this
>   

Yes, it's definitely a bug in interaction() rather than split() per se.  
I'll take a look and see if I can fix it.

Duncan Murdoch
>   
>> f <- interaction(list(iris[,1], iris[,2]))
>> f[16]
>>     
> [1] <NA>
>   
>> unclass(f)[16]
>>     
> [1] 785
>   
>> nlevels(f)
>>     
> [1] 781
>
> Maybe do_split dereferencing beyond allocated memory?
>
>   
>> interaction(list(iris[,1], iris[,2]), sep="-")
>>     
>
> does not produce <NA> at index 16
>
> -Matt
>
> On Tue, 2010-05-04 at 16:37 -0400, Jay Emerson wrote:
>   
>> I didn't see anything on this in the bug reports, and a search of the
>> archives had lots of false positives when searching on "split" to be
>> helpful.
>>
>> I don't view this as particularly interesting or useful, but wanted to
>> report it because I stumbled on it (and don't remember ever seeing
>> "invalid permissions" as part of a segfault).  Yes, I realize this is
>> a silly example that you wouldn't actually do, but... there may be
>> other more interesting cases with the same problem.  The following was
>> R-2.10.0 on Linux (with a Windows-64 2.11.0 difference to follow
>> below):
>>
>>     
>>> data(iris)
>>> split(1:nrow(iris), list(iris[,1], iris[,2]))
>>>       
>>  *** caught segfault ***
>> address 0x7fc806cd3d0c, cause 'invalid permissions'
>>
>> Traceback:
>>  1: split.default(1:nrow(iris), list(iris[, 1], iris[, 2]))
>>  2: split(1:nrow(iris), list(iris[, 1], iris[, 2]))
>>
>> Possible actions:
>> 1: abort (with core dump, if enabled)
>> 2: normal R exit
>> 3: exit R without saving workspace
>> 4: exit R saving workspace
>>
>> In contrast, R-2.11.0 in Windows-64:
>>
>>     
>>> data(iris)
>>> split(1:nrow(iris), list(iris[,1], iris[,2]))
>>>       
>> Traceback:
>>  1: split.default(1:nrow(iris), list(iris[, 1], iris[, 2]))
>>  2: split(1:nrow(iris), list(iris[, 1], iris[, 2]))
>> Error in split.default(1:nrow(iris), list(iris[, 1], iris[, 2])) :
>>   caught access violation - continue with care
>>
>> However, the same commands with drop=TRUE returns something, though
>> the answers differ.  In Linux:
>>
>>     
>>> a <- split(1:nrow(iris), list(iris[,1], iris[,2]), drop=TRUE)
>>> length(a)
>>>       
>> [1] 116
>>
>> And in Windows, differing only in the extra returned element, which I
>> don't think should probably be part of the answer (there are no
>> missing values in the iris data):
>>
>>     
>>> a <- split(1:nrow(iris), list(iris[,1], iris[,2]), drop=TRUE)
>>> length(a)
>>>       
>> [1] 117
>>     
>>> a[117]
>>>       
>> $<NA>
>> [1] 16
>>
>> --
>> John W. Emerson (Jay)
>> Associate Professor of Statistics
>> Department of Statistics
>> Yale University
>> http://www.stat.yale.edu/~jay
>>
>> ______________________________________________
>> 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
>



More information about the R-devel mailing list