Closed lukeaanderso closed 1 year ago
@lukeaanderso thanks. I assume this is in some old JDK < 10 since that code should only be used for legacy JVMs. I can replicate it on Debian testing with gcc 12 and JDK 8. Apparently the compiler does tail call optimization (TCO) and thus completely destroys our stack detection attempts. Please test rJava 1.0-8, by making dummy volatile I attempted to convince gcc to avoid TCO - seems to work at least for now.
Confirmed this works for me. Thanks for looking quickly.
Thanks!
@s-u this is great; any chance the latest version will be pushed to CRAN in the near future?
@s-u this is great; any chance the latest version will be pushed to CRAN in the near future?
I second this, please push the fixed version of rJava to CRAN, especially since this must affect anyone on Ubuntu 22.04, which comes with GCC 11 and Java 1.8 by default.
Details:
I can confirm that this affects also systems with GCC 11 and Java 1.8, e.g. https://github.com/HenrikBengtsson/CBI-software/issues/61. I now ran into the problem with Ubuntu 22.04, which comes with these version by default:
$ java -version
openjdk version "1.8.0_382"
OpenJDK Runtime Environment (build 1.8.0_382-8u382-ga-1~22.04.1-b05)
OpenJDK 64-Bit Server VM (build 25.382-b05, mixed mode)
$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Installing:
install.packages("https://rforge.net/rJava/snapshot/rJava_1.0-8.tar.gz")
works around the problem.
rJava 1.0-10 is on CRAN as of 2023-12-02. I can confirm that this updated version solves the problem reported here.
Installation of rJava now works and
> rJava::.jinit()
>
no longer blocks. I've confirmed this with Java JDK 1.8;
$ R CMD config --all | grep -E "^(JAVA|JAR)"
JAVA = /usr/bin/java
JAVAC = /usr/bin/javac
JAVAH = /usr/bin/javah
JAR = /usr/bin/jar
JAVA_HOME = /usr/lib/jvm/java-8-openjdk-amd64/jre
JAVA_LIBS = -L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm
JAVA_CPPFLAGS = -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux
and
$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Hi,
Thank you in advance for your time. I recently have had issues with rJava hanging when calling
.jinit
, very similar to what was linked here https://github.com/NixOS/nixpkgs/pull/171597 and https://github.com/s-u/rJava/issues/272. I pulled down the repository, rebuilt with debugging and started looking atRJAVA_JVM_STACK_WORKAROUND
. For context, the baseline hang looks like the below with debugging enabledand noticed that forcing
RJAVA_JVM_STACK_WORKAROUND=2
works, at the expense of reducing the stack, as noted in the warning. I started debugging by adding print statements within RinitJVM_with_paddingWith just
padding
being printed, the code stays in an infinite loopHowever when I print
last
ordummy
the loop breaks.This suggests the compiler is optimizing away these variables. I can either set the environment variable to 2, or maybe add some hack to my local install to try and help the compiler not remove the variable. Do you have any suggestions? On an older compiler I am not seeing these issues. For context here is my Makevars and gcc/g++ versions
Thank you again for your time
Luke Anderson