J.C.Rougier@durham.ac.uk
2001-Apr-30 13:34 UTC
[Rd] Segmentation fault linked to memory? (PR#929)
Hi Everyone, The following rather extreme claim on memory causes a segmentation fault on my installation: fred <- matrix(1:1200, 20, 60) littleOP <- function(x, y) { z <- as.vector(x) %*% t(as.vector(y)) dim(z) <- c(dim(x), dim(y)) z } littleOP(fred, fred) # this is OK littleOP(littleOP(fred, fred), fred) # whoops! Segmentation fault What's a bit strange is that if I do the outer product the `old-fashioned' way then I get the more usual error message:> (fred %o% fred) %o% fredError: cannot allocate vector of size 2555696 Kb Cheers, Jonathan. --please do not edit the information below-- Version: platform = sparc-sun-solaris2.7 arch = sparc os = solaris2.7 system = sparc, solaris2.7 status = major = 1 minor = 2.1 year = 2001 month = 01 day = 15 language = R Search Path: .GlobalEnv, Autoloads, package:base -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2001-Apr-30 14:57 UTC
[Rd] Segmentation fault linked to memory? (PR#929)
J.C.Rougier@durham.ac.uk writes:> Hi Everyone, > > The following rather extreme claim on memory causes a > segmentation fault on my installation: > > fred <- matrix(1:1200, 20, 60) > > littleOP <- function(x, y) > { > z <- as.vector(x) %*% t(as.vector(y)) > dim(z) <- c(dim(x), dim(y)) > z > } > > littleOP(fred, fred) # this is OK > littleOP(littleOP(fred, fred), fred) # whoops! Segmentation fault > > What's a bit strange is that if I do the outer product the > `old-fashioned' way then I get the more usual error message: > > > (fred %o% fred) %o% fred > Error: cannot allocate vector of size 2555696 Kb > > Cheers, Jonathan. > > --please do not edit the information below-- > > Version: > platform = sparc-sun-solaris2.7 > arch = sparc > os = solaris2.7 > system = sparc, solaris2.7 > status = > major = 1 > minor = 2.1 > year = 2001 > month = 01 > day = 15 > language = R > > Search Path: > .GlobalEnv, Autoloads, package:baseYou really ought to upgrade before reporting such bugs, but I get it with 1.2.3 as well. Looks like we have an integer overrun issue: At the point of the crash, we have succesfully allocated "ans" (gdb) p ans $25 = (SEXPREC *) 0x1fe8038 (gdb) p Rf_length(ans) $26 = 1728000000 (gdb) p/x Rf_length(ans) $27 = 0x66ff3000 however, measured in *bytes*, that length won't fit in 32 bits, and (gdb) p/x (Rf_length(ans)*8)/8 $31 = 0x6ff3000 So I suppose that the true length of ans is only 0x6ff3000 which fits fairly nicely with the segfault occurring when you try to access cell number 82*1440000 (gdb) p/x 82*1440000 $28 = 0x709c200 -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._