oracle / fastr

A high-performance implementation of the R programming language, built on GraalVM.
Other
626 stars 64 forks source link

Stackoverflow at FunctionDefinitionNode.execute(FunctionDefinitionNode.java:342) #206

Closed manticore-projects closed 1 year ago

manticore-projects commented 2 years ago

Greetings.

I would like call some R code from Java. On my Desktop computer, everything is working with GraalVM 22.3:

library(LDPD);

portfolio <- c(10,20,30,40,10)
defaults <- c(1,2,0,0,0)
PTMultiPeriodPD(portfolio, defaults, 0.3, cor.St = 0.3, kT = 5, kNS = 1000, conf.interval = 0.5)

Output: [1] 0.041068202 0.031549269 0.017002149 0.010844492 0.009993561

However, inside a VirtualBox Image (Linux guest, Linux host), with the same GraalVM 22.3 I get a StackOverflow (but only when call the R Script from inside the Java code. Calling the same R Script from FastR runs fine).

org.graalvm.polyglot.PolyglotException: com.oracle.truffle.r.runtime.RInternalError: java.lang.StackOverflowError
    at com.oracle.truffle.r.nodes.function.FunctionDefinitionNode.execute(FunctionDefinitionNode.java:342)
    at <R> parse(Unknown)
    at <R> sys.source(unknown.r:1:0-62)
    at <R> doTryCatch(unknown.r:1:0-86)
    at <R> tryCatchOne(unknown.r:1:0-49)
    at <R> tryCatchList(unknown.r:1:0-50)
    at <R> tryCatch(unknown.r:1:0-47)
    at <R> try(unknown.r:1-24:0-916)
    at <R> loadNamespace(unknown.r:1:0-91)
    at <R> asNamespace(unknown.r:1:0-75)
    at <R> namespaceImportFrom(unknown.r:1:0-14)
    at <R> loadNamespace(unknown.r:1:0-125)
    at <R> getNamespace(unknown.r:1:0-18)
    at <R> asNamespace(unknown.r:1:0-15)
    at <R> getExportedValue(unknown.r:1:0-14)
    at <R> ::(unknown.r:1:0-26)
    at <R> PTMultiPeriodPD(unknown.r:1:0-12)
    at <R> <repl wrapper>(Unnamed:5:72-167)
    at <R> null(Unnamed:1-5:0-167)
    at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:425)

OriginalInternalError.txt

What should I do to solve this please?

manticore-projects commented 1 year ago

After a lot of trial'n error I have found the JVM switch -Xss228k to be the culprit. Everything runs fine after removing it. Seem like much higher stack sizes are needed when running R code.