StackOverflowError in "process reaper" thread when using .jcall() or J() with java.lang.Runtime and exec
Overview
When attempting to execute the .jcall() or J() methods with the exec method in rJava, I encounter a java.lang.StackOverflowError in the "process reaper" thread. This issue occurs consistently when executing commands such as J(rt, "exec", "ls"), J(rt, "exec", "echo hello"), or similar exec calls.
Environment
Operating System: Linux Processor: aarch64 R Version: 4.3 rJava Version: 1.0.11, 1.0.6 Java Version: OpenJDK 11.0.20, Zulu11.70+15-CA
I've recreated this issue with every version of R-4.3.X, rJava-1.0.11 and 1.0.6, and openJDK 11.0.20, 11.0.22, 11.0.23. R is installed through conda, and I have tried installing both rJava and openJDK through conda and source. I am unable to update java due to a reliance on jdx.
Steps to Reproduce:
Create a conda environment with the following yaml and command
name: envName
channels:
- conda-forge
- defaults
dependencies:
- openjdk=11.0.23=h4f80945_0
- r-base=4.3.1=hbff713c_6
- r-rjava=1.0_11=r43h25e906a_0
conda env create -f <path/to/above/file.yaml>
Run the following in wither an Rscript of R session:
library(rJava)
rt <- J("java.lang.Runtime", "getRuntime")
J(rt, "exec", "echo hello")
Expected Outcome:
[1] "Java-Object{Process[pid=1780931, exitValue=0]}"
Actual Outcome:
[1] "Java-Object{Process[pid=2596058, exitValue=\"not exited\"]}"
> Exception in thread "process reaper" java.lang.StackOverflowError
at java.base/java.lang.invoke.MethodType.equals(MethodType.java:797)
at java.base/java.lang.invoke.MethodType.equals(MethodType.java:792)
at java.base/java.lang.invoke.MethodType$ConcurrentWeakInternSet$WeakEntry.equals(MethodType.java:1341)
at java.base/java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:940)
at java.base/java.lang.invoke.MethodType$ConcurrentWeakInternSet.get(MethodType.java:1279)
at java.base/java.lang.invoke.MethodType.makeImpl(MethodType.java:300)
at java.base/java.lang.invoke.MethodTypeForm.canonicalize(MethodTypeForm.java:355)
at java.base/java.lang.invoke.MethodTypeForm.findForm(MethodTypeForm.java:317)
at java.base/java.lang.invoke.MethodType.makeImpl(MethodType.java:315)
at java.base/java.lang.invoke.MethodType.insertParameterTypes(MethodType.java:410)
at java.base/java.lang.invoke.VarHandle$AccessDescriptor.<init>(VarHandle.java:1853)
at java.base/java.lang.invoke.MethodHandleNatives.varHandleOperationLinkerMethod(MethodHandleNatives.java:518)
at java.base/java.lang.invoke.MethodHandleNatives.linkMethodImpl(MethodHandleNatives.java:462)
at java.base/java.lang.invoke.MethodHandleNatives.linkMethod(MethodHandleNatives.java:450)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:932)
at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:907)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2079)
at java.base/java.lang.ProcessHandleImpl$1.run(ProcessHandleImpl.java:169)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Side Note
I encountered this issue on Linux x86-64 as well. However, I eventually got lucky and downloaded a version of r-base, rJava, and java that worked. I have not yet found a similar solution on ARM.