Joshua Ulrich
2012-May-06 02:39 UTC
[Rd] unlist crashes 32-bit R on WinXP when use.names=TRUE
Hi all, I experienced a crash in R-2.15.0 on 32-bit Windows XP (sessionInfo below) when running the piece of code below. I cannot replicate the error on 64-bit Linux, 64-bit Windows, or 32-bit R running under 64-bit Windows. I do not have, and could not find, a 32-bit version of Linux to test this.> NOW <- Sys.time() > FUTURE <- NOW+1:1e7 > crash <- as.character(FUTURE)Error in unlist(unclass(x)[1L:3L]) : promise already under evaluation: recursive default argument reference or earlier problems?> traceback()Error: C stack usage is too close to the limit> # evaluating an expression at this point would cause R to exit ungracefullyHere's an example that avoids a lot of unnecessary code: L1 <- list(one=1:1e6, two=1:1e6, three=1:1e6) # no issue with smaller list elements U1 <- unlist(L1, recursive=TRUE, use.names=TRUE) C1 <- c(L1, recursive=TRUE, use.names=TRUE) L2 <- list(one=1:1e7, two=1:1e7, three=1:1e7) # crashes after ~2min with error above U2 <- unlist(L2, recursive=TRUE, use.names=TRUE) C2 <- c(L2, recursive=TRUE, use.names=TRUE) # no issue if use.names=FALSE U3 <- unlist(L2, recursive=TRUE, use.names=FALSE) C3 <- c(L2, recursive=TRUE, use.names=FALSE) I took a look at do_unlist and do_c_dflt in bind.c, but I stopped at NewExtractNames because it is a bit beyond my current understanding. Any thoughts?> sessionInfo()R version 2.15.0 (2012-03-30) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base Please let me know if I forgot anything or if there's anything I can do to help. Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com R/Finance 2012: Applied Finance with R www.RinFinance.com
Duncan Murdoch
2012-May-06 10:43 UTC
[Rd] unlist crashes 32-bit R on WinXP when use.names=TRUE
On 12-05-05 10:39 PM, Joshua Ulrich wrote:> Hi all, > > I experienced a crash in R-2.15.0 on 32-bit Windows XP (sessionInfo > below) when running the piece of code below. I cannot replicate the > error on 64-bit Linux, 64-bit Windows, or 32-bit R running under > 64-bit Windows. I do not have, and could not find, a 32-bit version > of Linux to test this. > >> NOW<- Sys.time() >> FUTURE<- NOW+1:1e7 >> crash<- as.character(FUTURE) > Error in unlist(unclass(x)[1L:3L]) : > promise already under evaluation: recursive default argument > reference or earlier problems? >> traceback() > Error: C stack usage is too close to the limit >> # evaluating an expression at this point would cause R to exit ungracefully > > Here's an example that avoids a lot of unnecessary code: > > L1<- list(one=1:1e6, two=1:1e6, three=1:1e6) > # no issue with smaller list elements > U1<- unlist(L1, recursive=TRUE, use.names=TRUE) > C1<- c(L1, recursive=TRUE, use.names=TRUE) > > L2<- list(one=1:1e7, two=1:1e7, three=1:1e7) > # crashes after ~2min with error above > U2<- unlist(L2, recursive=TRUE, use.names=TRUE) > C2<- c(L2, recursive=TRUE, use.names=TRUE) > # no issue if use.names=FALSE > U3<- unlist(L2, recursive=TRUE, use.names=FALSE) > C3<- c(L2, recursive=TRUE, use.names=FALSE) > > I took a look at do_unlist and do_c_dflt in bind.c, but I stopped at > NewExtractNames because it is a bit beyond my current understanding. > Any thoughts?I would guess that some loop in the C code is using alloca to allocate temporary storage on the stack, and it's running out of stack space. I'll take a look... Duncan Murdoch> >> sessionInfo() > R version 2.15.0 (2012-03-30) > Platform: i386-pc-mingw32/i386 (32-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > Please let me know if I forgot anything or if there's anything I can do to help. > > Best, > -- > Joshua Ulrich | FOSS Trading: www.fosstrading.com > > R/Finance 2012: Applied Finance with R > www.RinFinance.com > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Duncan Murdoch
2012-May-06 16:22 UTC
[Rd] unlist crashes 32-bit R on WinXP when use.names=TRUE
On 12-05-05 10:39 PM, Joshua Ulrich wrote:> Hi all, > > I experienced a crash in R-2.15.0 on 32-bit Windows XP (sessionInfo > below) when running the piece of code below. I cannot replicate the > error on 64-bit Linux, 64-bit Windows, or 32-bit R running under > 64-bit Windows. I do not have, and could not find, a 32-bit version > of Linux to test this. > >> NOW<- Sys.time() >> FUTURE<- NOW+1:1e7 >> crash<- as.character(FUTURE) > Error in unlist(unclass(x)[1L:3L]) : > promise already under evaluation: recursive default argument > reference or earlier problems? >> traceback() > Error: C stack usage is too close to the limit >> # evaluating an expression at this point would cause R to exit ungracefullyI think what's happening is this: R tries to allocate one of those names, and fails. It tries to display an error message, but that fails too, because it needs memory for the message. You get a strange error, and R is left unstable. In R-devel, R appears to go into an infinite loop. I'm not sure we'll fix R 2.15.x unless it's a relatively easy fix, but I'll try to get R-devel to at least report an error. Duncan Murdoch> > Here's an example that avoids a lot of unnecessary code: > > L1<- list(one=1:1e6, two=1:1e6, three=1:1e6) > # no issue with smaller list elements > U1<- unlist(L1, recursive=TRUE, use.names=TRUE) > C1<- c(L1, recursive=TRUE, use.names=TRUE) > > L2<- list(one=1:1e7, two=1:1e7, three=1:1e7) > # crashes after ~2min with error above > U2<- unlist(L2, recursive=TRUE, use.names=TRUE) > C2<- c(L2, recursive=TRUE, use.names=TRUE) > # no issue if use.names=FALSE > U3<- unlist(L2, recursive=TRUE, use.names=FALSE) > C3<- c(L2, recursive=TRUE, use.names=FALSE) > > I took a look at do_unlist and do_c_dflt in bind.c, but I stopped at > NewExtractNames because it is a bit beyond my current understanding. > Any thoughts? > >> sessionInfo() > R version 2.15.0 (2012-03-30) > Platform: i386-pc-mingw32/i386 (32-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > Please let me know if I forgot anything or if there's anything I can do to help. > > Best, > -- > Joshua Ulrich | FOSS Trading: www.fosstrading.com > > R/Finance 2012: Applied Finance with R > www.RinFinance.com > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Apparently Analagous Threads
- Wichmann-Hill Random Number Generator and the Birthday Problem
- Should c(..., recursive = TRUE) and unlist(x, recursive = TRUE) recurse into expression vectors?
- Result of 'seq' doesn't use compact internal representation
- R programming question
- Result of 'seq' doesn't use compact internal representation