Skip to content
Prev 13230 / 21307 Next

[Bioc-devel] Error: node stack overflow

Hi Zheng,

I can totally reproduce this on my Ubuntu laptop:

   library(rJava)
   library(IRanges)
   unique(IRanges())
   # Error in validObject(.Object) :
   #   invalid class ?MethodWithNext? object: Error : C stack usage 
7969396 is too close to the limit

See my seesionInfo() at the end of this email.

Probably related to this (but not 100% sure) loading rJava seems
to break selectMethod().

More precisely: The rJava package defines some "unique" S4 methods
and the BiocGenerics package defines (and exports) the unique() S4
generic with the following statement:

   setGeneric("unique", signature="x")

Here is what happens when loading the rJava package first:

   library(rJava)
   library(BiocGenerics)

   setClass("A", slots=c(a="integer"))
   setMethod("unique", "A",
     function(x, incomparables=FALSE, ...) {x at a <- unique(x at a); x}
   )

   selectMethod("unique", "A")
   # Method Definition (Class "derivedDefaultMethod"):
   #
   # function (x, incomparables = FALSE, ...)
   # UseMethod("unique")
   # <bytecode: 0x4127140>
   # <environment: namespace:base>
   #
   # Signatures:
   #         x
   # target  "A"
   # defined "ANY"

selectMethod() doesn't find the method for A objects!

It seems that selectMethod() is looking in the method table for
the implicit unique() generic defined in rJava instead of the
explicit unique() generic defined in BiocGenerics. If we tell
selectMethod() which generic to consider, then it finds the method
for A objects:

   selectMethod(BiocGenerics::unique, "A")
   # Method Definition:
   #
   # function (x, incomparables = FALSE, ...)
   # {
   #   x at a <- unique(x at a)
   #   x
   # }
   #
   # Signatures:
   #         x
   # target  "A"
   # defined "A"

In order to reproduce the above problem without the BiocGenerics
package in the equation, it's not enough to do:

   library(rJava)
   setGeneric("unique", signature="x")
   etc...

The setGeneric("unique", signature="x") statement must be put in
a package. I've created a minimalist package on GitHub that just
wraps this statement:

   https://github.com/Bioconductor/uniqueGeneric

This package can be used instead of BiocGenerics to reproduce the
problem above.

I'm not 100% sure that this problem is related to the issue you
reported originally but it seems very likely to me.

Not quite sure what the next step should be. I've been told by
some R core developers that there are known interaction issues
between Java, rJava and R that are currently being worked on.
Someone should ask on the R-devel mailing list or directly to
Simon Urbanek, the rJava author, for more information about this.

H.

 > sessionInfo()
R Under development (unstable) (2018-02-26 r74306)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS: /home/hpages/R/R-3.5.r74306/lib/libRblas.so
LAPACK: /home/hpages/R/R-3.5.r74306/lib/libRlapack.so

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] BiocGenerics_0.25.3 rJava_0.9-9

loaded via a namespace (and not attached):
[1] compiler_3.5.0 parallel_3.5.0
On 04/02/2018 11:47 AM, Vincent Carey wrote: