[R] C stack error in as.vector() starting in R 3.3.0

luke-tierney at uiowa.edu luke-tierney at uiowa.edu
Thu Jul 7 01:06:50 CEST 2016


I cannot reproduce this.  My best guess is that there is a problem,
maybe a version incompatibility, with one of the packages loaded when
load("problem.method.rdata"). This includes

adegenet
apex
copula
Rcpp
DBI
sp
colorspace

and any dependencies these are bringing in.

Best,

luke

On Fri, 1 Jul 2016, Eric Archer - NOAA Federal wrote:

> Apologies for the long post. This is an issue I have been struggling with
> and I have tried to be as complete, to the point, and reproducible as
> possible.
>
> In documenting a package with roxygen2, I have come across an error that
> does not occur in R 3.2.4 revised, but does occur in R 3.3.0 and 3.3.1.
> Using traceback() and debug(), I've traced the error to a call made to
> as.vector(x, "character") that seems to get stuck in a loop which
> culminates in this error:
>
> Error: C stack usage  7970892 is too close to the limit
>
> The object that causes this error is of a signature type for a method. With
> some playing around, I've been able to work out that the error is actually
> associated with the method that roxygen2 creates when doing its magic.
> Something happens when this method definition with its associated
> environment is in the workspace that causes the error.
>
> At this point, I should stress again that the error does NOT occur in R
> 3.2.4 revised or earlier, but does occur in R 3.3.0 and 3.3.1. I have also
> tested this with several versions of roxygen2 and that does not make a
> difference. Thus, my ultimate question is what has changed in R 3.3.0 that
> would lead to this so that the roxygen2 maintainers can correct it?
>
> As a test, I created a signature identical to the one that causes the error
> and tried the as.vector() command that would generate the loop. I don't get
> the error in my command line generated object, nor with the object that is
> extracted from the method definition. However, when I load the method
> definition into the workspace, the error will happen on either my command
> line generated object, or the one extracted from the method definition and
> will not stop happening until I restart R.
>
> I have reported this error as an issue on the roxygen2 GitHub repository
> and it has been crossposted by another user who had a similar experience
> with a different package on the devtools repository. Those posts, which
> contain more information are here:
>
> https://github.com/klutometis/roxygen/issues/475
> https://github.com/hadley/devtools/issues/1234
>
> Below is the result of sessionInfo() and the output of a session
> demonstrating the effect. The files used are in a zip file here:
> https://github.com/klutometis/roxygen/files/335417/error.test.rdata.files.zip
>
> > sessionInfo()
> R version 3.3.0 (2016-05-03)
> Platform: x86_64-apple-darwin13.4.0 (64-bit)
> Running under: OS X 10.11.5 (El Capitan)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] tools_3.3.0
>
>> rm(list = ls())
>>
>> # Create test class and method
>> setClass(Class = "gtypes", slots = c(loci = "data.frame", ploidy =
> "numeric"), package = "roxygen_devtest")
>> setGeneric("nInd", function(x, ...) standardGeneric("nInd"), package =
> "adegenet")
> [1] "nInd"
>> setMethod("nInd", "gtypes", function(x, ...) nrow(x at loci) / x at ploidy)
> [1] "nInd"
>>
>> test.method <- getMethod("nInd", "gtypes")
>> str(test.method)
> Formal class 'MethodDefinition' [package "methods"] with 4 slots
>  ..@ .Data  :function (x, ...)
>  ..@ target :Formal class 'signature' [package "methods"] with 3 slots
>  .. .. ..@ .Data  : chr "gtypes"
>  .. .. ..@ names  : chr "x"
>  .. .. ..@ package: chr "roxygen_devtest"
>  ..@ defined:Formal class 'signature' [package "methods"] with 3 slots
>  .. .. ..@ .Data  : chr "gtypes"
>  .. .. ..@ names  : chr "x"
>  .. .. ..@ package: chr "roxygen_devtest"
>  ..@ generic: atomic [1:1] nInd
>  .. ..- attr(*, "package")= chr "adegenet"
>>
>> # No error:
>> as.vector(test.method at defined, "character")
> [1] "gtypes"
>>
>> # This is the method that generates the error
>> load("problem.method.rdata")
>>
>> # Notice the difference in the environments of the two functions:
>> test.method at .Data
> function (x, ...)
> nrow(x at loci)/x at ploidy
>> problem.method at .Data
> function (x, ...)
> nrow(x at loci)/x at ploidy
> <environment: 0x101f85040>
>>
>> # Swap the problem function for the one I created:
>> problem.method at .Data <- test.method at .Data
>> save(problem.method, file = "fixed.method.rdata")
>>
>> # Here's the error (both with my method and the original):
>> as.vector(test.method at defined, "character")
> Error: C stack usage  7970892 is too close to the limit
>> as.vector(problem.method at defined, "character")
> Error: C stack usage  7970892 is too close to the limit
>
> Restarting R session...
>
>> # *** Restart R for this to work ***
>> rm(list = ls())
>>
>> load("fixed.method.rdata")
>> as.vector(problem.method at defined, "character")
> [1] "gtypes"
>
> ----
>
> *Eric Archer, Ph.D.*
> Southwest Fisheries Science Center
> NMFS, NOAA
> 8901 La Jolla Shores Drive
> La Jolla, CA 92037 USA
> 858-546-7121 (work)
> 858-546-7003 (FAX)
>
> Marine Mammal Genetics Group: swfsc.noaa.gov/mmtd-mmgenetics
> ETP Cetacean Assessment Program: swfsc.noaa.gov/mmtd-etp
> https://github/ericarcher
>
> "
>
>
> *The universe doesn't care what you believe. The wonderful thing about
> science is that it   doesn't ask for your faith, it just asks   for your
> eyes.*"  - Randall Munroe
>
> "*Lighthouses are more helpful than churches.*"
>   - Benjamin Franklin
>
>   "*...but I'll take a GPS over either one.*"
>       - John C. "Craig" George
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-help mailing list