Compatibility across Julia 1+ versions

https://github.com/JuliaLang/julia/blob/v1.0.4/src/codegen.cpp#L1191

if (strcmp(f, "jl_fptr_args") && strcmp(f, "jl_fptr_sparam"))

Should && be ||?

[quote=“thautwarm, post:20, topic:27196”]

I have submitted the reproducer (too, same cause, similar enough segfault?). I just noticed now:

(julia-1.0.4) pkg> st
    Status `~/julia-1.0.4/Project.toml`
  [e53ffe30] Py2Jl v0.1.0 #0dbff54 (https://github.com/JuliaCN/Py2Jl.jl)

[EDIT: after exiting Julia and entering again they’re all there, the segfault seems to have trimmed the list… maybe a clue to someone, should I report that too? Done it.] None of the dependencies are there (or any other package). That’s strange in of itself to me, but at least shows that only this one package is needed to reproduce (and the fault is Julia, not it).

|| would be a trivially true logic. strcmp returns the three way comparison result, I.e. 0 if the inputs are the same.

I just don’t know why this line raises segmentation fault.

Errr, well, if anything || or && is definitely not the reason. If the backtrace is real, it just means f is a bad pointer.

I would like to agree with ExpandingMan. I too am using Julia in the “big data” world and this issue is almost a show stopper. JDBC is not on my radar right now but Accumulo and Hadoop are.

My two cents

1 Like

Well, we’re in luck thanks to the ever-diligent core developers. Java interop should be restored already in 1.3 by simply setting an environment variable. I plan on helping to make sure that JavaCall.jl and JDBC.jl are usable again in 1.3.

I would appreciate a description of what the disadvantages of setting JULIA_COPY_STACKS=true will be.

1 Like

I may have spoken too soon. See here. I still cannot get anything running at all. Hopefully that issue can get re-opened, otherwise I’ll open a new one.

I did read about that JULIA_COPY_STACKS business. I gave it a try but got an error. i.e. With 1.3.0-rc2.0 and Java 11, it didn’t just work.

Spoiler alert: Here’s the issue **ERROR:** UndefVarError: penv not defined

The whole mishmash is included below.

**_** _ **_** **(_)** **_** | Documentation: https://docs.julialang.org

**(_)** | **(_)** **(_)** |

_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.

| | | | | | |/ _` | |

| | |_| | | | (_| | | Version 1.3.0-rc2.0 (2019-09-12)

_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release

|__/ |

**julia>** ENV["JULIA_COPY_STACKS"] = true

**julia>** using JavaCall

**julia>** JavaCall.init(["-Xmx128M"])

signal (11): Segmentation fault: 11

in expression starting at REPL[2]:1

unknown function (ip: 0x13742e2b3)

Allocations: 6134837 (Pool: 6133375; Big: 1462); GC: 6

**ERROR:** StackOverflowError:

Stacktrace:

[1] **init(** ::Array{String,1} **)** at **/Users/geoffryroberts/.julia/packages/JavaCall/toamy/src/jvm.jl:176**

[2] top-level scope at **REPL[2]:1**

**julia>** jlm = @jimport java.lang.Math

JavaObject{Symbol("java.lang.Math")}

**julia>** jcall(jlm, "sin", jdouble, (jdouble,), pi/2)

**ERROR:** UndefVarError: penv not defined

Stacktrace:

[1] **jcall(** ::Type{JavaObject{Symbol("java.lang.Math")}}, ::String, ::Type, ::Tuple{DataType}, ::Float64 **)** at **/Users/geoffryroberts/.julia/packages/JavaCall/toamy/src/core.jl:139**

[2] top-level scope at **REPL[4]:1**

**julia>**

I feel incredibly stupid, it seems this failed because I set JULIA_COPY_STACKS to true instead of 1 or yes, which I would have known that I should have done if I looked at Jeff’s commit.

This seems to be working fine for me now. There are a few test failures on JavaCall.jl but surely nothing that can’t be fixed.

1 Like

Please open an issue about this though: it should not fail like this because the environment variable was set to an unexpected value.

1 Like

Slower task switching: the old tasks stack needs to be copied away from the main stack location and the new tasks stack needs to be copied to the main stack location on each task switch, instead of just changing the stack pointer to be on a different stack.

2 Likes

Why not? It only fails once it gets to JavaCall.init(), at which point presumably it’s failing because always_copy_stacks == 0 and exactly the same thing is going wrong that was going wrong in the first place. Don’t see what Julia itself can do about that. Presumably we should add something to JavaCall.init() that checks whether always_copy_stacks was set correctly (in fact, I wonder if there is a way of doing that without having to also check the environment,because that could go wrong in a number of ways). Regardless, it seems like the responsibility falls on JavaCall.jl now, not on Julia.

If the environment variable is set to an unexpected value I think that Julia should arguably either error or warn about that.

Edit: done — https://github.com/JuliaLang/julia/pull/33318

2 Likes

JULIA_COPY_STACKS

set it to true set it to 1, I still get the error ERROR: UndefVarError: penv not defined

I’m not quite sure what’s causing that, but I have seen the JavaCall unit tests and there are some failures. So we still have some fixing to do for 1.3, but presumably these are all JavaCall fixes and no more scary show-stopping language incompatibilities.

1 Like

I am new to JavaCall

It would appear that the following error is causing penv NOT to be set. Line 177 of jvm.jl seems to be the culprit here. Line 177 is the ccall function.

**julia>**JavaCall.init([“-Xmx128M”])

signal (11): Segmentation fault: 11
in expression starting at REPL[3]:1
unknown function (ip: 0x139b582b3)
Allocations: 7924029 (Pool: 7922285; Big: 1744); GC: 9
ERROR: StackOverflowError:
Stacktrace:
[1] init( ::Array{String,1} ) at /Users/geoffryroberts/hazWk/JavaCall.jl/src/jvm.jl:177
[2] top-level scope at REPL[3]:1

Any chance of getting the OpenJDK people to implement the aforementioned patch? Has anyone tried?

According to @avik they have in Java 11.

It then follows that if I am using JDK 11, and Julia 1.3, and I set the environment variable JULIA_COPY_STACKS=1; then JavaCall should work. I am afraid it does not.

Ubuntu 19.04
OpenJDK = 11.0.4
Julia = 1.3.0-rc2.0

julia> using JavaCall
julia> JavaCall.init([“-Xmx128M”])
Segmentation fault (core dumped)

Julia crashes at this point.