cberry@tajo.ucsd.edu
2000-Feb-17 00:10 UTC
[Rd] "a.matrix[a.char.matrix]<- " crashes R (PR#447)
To wit: ---> junk <- array(3,c(10,3),dimnames=list(as.character(1:10),as.character(1:3))) > junk[cbind(as.character(1:5),as.character(c(1,2,3,2,3)))] <- 20 > > junkProcess R segmentation violation (core dumped) at Wed Feb 16 15:57:49 2000 --- I know that the use of a ***character*** matrix is not documented for this context. Still, it should not crash R. In addition to 0.90.1, this also happens on rw0991b --please do not edit the information below-- Version: platform = sparc-sun-solaris2.7 arch = sparc os = solaris2.7 system = sparc, solaris2.7 status = major = 0 minor = 90.1 year = 1999 month = December day = 15 language = R Search Path: .GlobalEnv, Autoloads, package:base -- Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry@tajo.ucsd.edu UC San Diego http://hacuna.ucsd.edu/members/ccb.html La Jolla, San Diego 92093-0645 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
p.dalgaard@biostat.ku.dk
2000-Feb-18 16:05 UTC
[Rd] "a.matrix[a.char.matrix]<- " crashes R (PR#447)
Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:> Still crashes for me![Directed back to R-bugs, and please keep it there!] OK, there are two issues here: (a) matrix subscripting doesn't work with character type. Plain and simple. A matrix subscript just get flattened into a character vector and then used for subscripting. We might want to give an error instead or simply implement the expected behaviour, but not this close to a major release, I think. (Splus cant do this either) (b) There's a bug in string indexing: x<-1:2 x[c("2","2")]<-2 x Program received signal SIGSEGV, Segmentation fault. <etc> It seems to happen only when there are repeated indices. The bug is that the names component of x which is originally empty isn't filled with "" for the first elements as it usually is but has NULL (0x0) pointers there. Will dig deeper... -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian Ripley
2000-Feb-18 17:08 UTC
[Rd] "a.matrix[a.char.matrix]<- " crashes R (PR#447)
> From: p.dalgaard@biostat.ku.dk > Date: Fri, 18 Feb 2000 17:05:50 +0100 (MET) > > Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes: > > > Still crashes for me! > > [Directed back to R-bugs, and please keep it there!] > > OK, there are two issues here: > > (a) matrix subscripting doesn't work with character type. Plain and > simple. A matrix subscript just get flattened into a character vector > and then used for subscripting. We might want to give an error instead > or simply implement the expected behaviour, but not this close to a > major release, I think. (Splus cant do this either)I think that is the correct behaviour. (What is the expected behaviour? It is what I expected.) A k-index (aka matrix or array subset) is supposed to give the indices of the elements to be extracted/replaced. I suppose character values could be matched to dimnames, but that would be a new idea. We might want to *warn*. On the other hand, S-PLUS's print routine seems to ignore the added elements, and R loses the dim attribute.> (b) There's a bug in string indexing: > > x<-1:2 > x[c("2","2")]<-2 > x > > Program received signal SIGSEGV, Segmentation fault. <etc> > > It seems to happen only when there are repeated indices. The bug isrepeated *new *indices. The hackery in StringSubscript was copying the wrong string as a name for duplicate string indices. Fixed. -- 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._