-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JVM fails to load in 1.1 (JavaCall.jl) #31104
Comments
@JeffBezanson suggested trying with |
Maybe related? JuliaInterop/RCall.jl#293 |
I get a hang instead of a stack overflow:
stack trace:
It looks like the JVM is trying to throw an exception. I'll see if I can find the error message. |
Jeff and I spent a lot of time looking into this today. The story is basically as follows:
The reason that Jeff is trying to get ALWAYS_COPY_STACKS to go back to using the actual process stack, which may make this work temporarily, but certainly not on the pre-built binaries. A full fix will require an enhancement to the JNI to allow setting the stack extents of the current stack before entering the JVM thread. |
(Alternatively, we could have a way of always executing a ccall on the current thread's main stack). |
This is the relevant function in the current jdk, though it looks a bit different in JDK8: https://github.com/unofficial-openjdk/openjdk/blob/3e601613f8c323f1129fa3f8aac389b90456c8c7/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp#L308 |
this makes it possible to work around #31104
That would be much better. Honestly, not many people will use this if it needs recompiling Julia. |
We could possibly enable this with a command line option too. |
That'd be great, thanks! |
We've decided that the right way to address this is to add a new calling convention to Some other options considered were (1) provide builds of openjdk (via BinaryBuilder) patched to work around the problem (we could still potentially do this if it's practical), and (2) (long term) try to get the JNI to add a call to inform it that the stack has switched. For 1.2, the most we can do is fix the |
I think patched builds of openjdk are not practical for the users of this feature. Most likely the end users of java software are enterprises who are unlikely to want to pick an openjdk we provide. Providing a patch to openjdk itself may be ok in hopes of future releases fixing this issue. |
I think the utility of that option is for people who are using a Julia library that depends on a Java library but the user doesn't know or care that it's implemented in Java—they just want it to work. For that use case, the JVM is no different than any other binary artifact that we load and call into. |
this makes it possible to work around #31104
So I'm assuming one would need a non-default build of Julia for this to work in 1.2, correct? |
this makes it possible to work around #31104
Allows working around #31104 (JVM interop)
Allows working around #31104 (JVM interop)
Added environment variable to work around this for now. |
Allows working around #31104 (JVM interop)
What needs to be done here (thinking about the 1.4 milestone). |
Thanks to @c42f for bringing the current open state of this issue to my attention. Outstanding Issues:
The above sound like separate platform specific issues for Julia. Given that
I suggest that we close this issue. Do you agree @aviks ? |
There is |
JVM may load, but I feel it may be useful to keep this issue open (perhaps we rename it?) to track JVM integration issues. Provided that some of the great analysis further up the thread is still relevant. |
Wouldn't it be better to close this and have newer issues to track JavaCall stuff, or track it on the JavaCall.jl repo? |
Please reopen if we should keep it around. |
Sorry to dig up an old issue, but has this new calling convention been implemented, or is it still planned? I'm asking because since Qt version 6.5, QML has a new stack bounds checker, which makes QML.jl fail in the same way as JavaCall.jl. Thanks for the great analysis of this problem, BTW. |
My solution is to implement a worker that runs on the root task. Then whenever we need to do something that requires the root task, send the call over a channel to the worker: https://github.com/mkitti/TaskWorkers.jl The package probably needs to be revisited, but overall the idea is sound I think. |
Thanks, this is a golden tip, we actually don't need TaskWorkers.jl, since for QML.jl it is sufficient to process the events on the root task and then launch the REPL on a new task, I didn't know that was possible. |
When I started with Julia, it was not possible. The REPL backend used not to be using the root task. I had to change it: #35048 . I had been using Julia for about two months at this point, and this pull request getting processed made me realize this was a project I could to which I could meaningfully contribute. @barche , you might have an interest in #35726 since checking if we are on the root task is currently not publicly documented API. |
In 1.1, trying to initialise the java virtual machine in Julia via JavaCall.jl causes a stack overflow error. It works correctly when the code is loaded with
-i
or-e
but fails when used from the REPL.Ref: JuliaInterop/JavaCall.jl#96
The call in question is the
JNI_CreateJavaVM
function in the JVM. More information about the JVM invocation API is at https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.htmlThis is a regression from 1.0.x
The text was updated successfully, but these errors were encountered: