From shotwelm at musc.edu  Wed May  5 00:45:48 2010
From: shotwelm at musc.edu (Matt Shotwell)
Date: Tue, 04 May 2010 18:45:48 -0400
Subject: [Rd] split() bug? Inconsistent Windows/Linux behavior.
In-Reply-To: <p2xd4588dec1005041337y8ad4926od55881987e5ec177@mail.gmail.com>
References: <p2xd4588dec1005041337y8ad4926od55881987e5ec177@mail.gmail.com>
Message-ID: <1273013148.6574.15.camel@deacon>

This is odd, I think it may have something to do with this

> 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



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