Skip to content

JavaCall crashes Julia 1.6.3 on macOS #151

Description

@KenziTrader

In Julia 1.6.3, JavaCall.init() causes a Segmentation fault. The same happens with version 1.7.0-rc1. It works in version 1.6.2.

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.6.3
Commit ae8452a9e0 (2021-09-23 17:34 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.5.0)
  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, haswell)
Environment:
  JULIA_COPY_STACKS = 1

julia> using JavaCall

julia> JavaCall.init()

signal (11): Segmentation fault: 11
in expression starting at REPL[3]:1
unknown function (ip: 0x14151552d)
Allocations: 5345101 (Pool: 5343172; Big: 1929); GC: 7
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0-rc1 (2021-09-12)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.7.0-rc1
Commit 9eade6195e (2021-09-12 06:45 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.6.0)
  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, haswell)
Environment:
  JULIA_COPY_STACKS = 1

julia> using JavaCall

julia> JavaCall.init()

signal (11): Segmentation fault: 11
in expression starting at REPL[3]:1
unknown function (ip: 0x14655352d)
Allocations: 4830421 (Pool: 4828125; Big: 2296); GC: 6

Activity

  1. mkitti commented on Oct 11, 2021

    @mkitti
    Member

    Thanks for the issue. Have you tried this on any other operating systems?

  2. mkitti commented on Oct 11, 2021

    @mkitti
    Member

    I just tried 1.6.3 on Linux and Windows:

    Linux:

    julia> using JavaCall
    
    julia> JavaCall.init()
    
    julia> jls = @jimport java.lang.System
    JavaObject{Symbol("java.lang.System")}
    
    julia> out = jfield(jls,"out",@jimport java.io.PrintStream)
    JavaObject{Symbol("java.io.PrintStream")}(JavaCall.JavaLocalRef(Ptr{Nothing} @0x00000000023f1598))
    
    julia> jcall(out,"println",Nothing,(JString,),"Hello Java")
    Hello Java
    
    julia> versioninfo()
    Julia Version 1.6.3
    Commit ae8452a9e0 (2021-09-23 17:34 UTC)
    Platform Info:
      OS: Linux (x86_64-pc-linux-gnu)
      CPU: AMD FX(tm)-8350 Eight-Core Processor
      WORD_SIZE: 64
      LIBM: libopenlibm
      LLVM: libLLVM-11.0.1 (ORCJIT, bdver1)
    Environment:
      JULIA_COPY_STACKS = 1

    Windows:

    julia> using JavaCall
    [ Info: Precompiling JavaCall [494afd89-becb-516b-aafa-70d2670c0337]
    
    julia> JavaCall.init()
    
    julia>
    
    julia> jls = @jimport java.lang.System
    JavaObject{Symbol("java.lang.System")}
    
    julia> out = jfield(jls, "out", @jimport java.io.PrintStream )
    JavaObject{Symbol("java.io.PrintStream")}(JavaLocalRef(Ptr{Nothing} @0x0000000059c15380))
    
    julia> jcall(out, "println", Nothing, (JString,), "Hello world")
    Hello world
    
    julia> versioninfo()
    Julia Version 1.6.3
    Commit ae8452a9e0 (2021-09-23 17:34 UTC)
    Platform Info:
      OS: Windows (x86_64-w64-mingw32)
      CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
      WORD_SIZE: 64
      LIBM: libopenlibm
      LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
  3. KenziTrader commented on Oct 11, 2021

    @KenziTrader
    Author

    In Julia 1.6.2 I also get the Segmentation fault but it doesn't crash. In v1.6.3 or v1.7.0-rc1 is crashes the Julia session. I also tried it without JULIA_COPY_STACKS = 1.

                   _
       _       _ _(_)_     |  Documentation: https://docs.julialang.org
      (_)     | (_) (_)    |
       _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
      | | | | | | |/ _` |  |
      | | |_| | | | (_| |  |  Version 1.6.2 (2021-07-14)
     _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
    |__/                   |
    
    julia> using JavaCall; JavaCall.init()
    
    signal (11): Segmentation fault: 11
    in expression starting at REPL[1]:1
    unknown function (ip: 0x14f18752d)
    Allocations: 3030525 (Pool: 3029395; Big: 1130); GC: 4
    
    julia> jls = @jimport java.lang.System
    JavaObject{Symbol("java.lang.System")}
    
    julia> jcall(jls, "getProperty", JString, (JString,), "java.version")
    "11.0.12"
    
    julia> versioninfo()
    Julia Version 1.6.2
    Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
    Platform Info:
      OS: macOS (x86_64-apple-darwin18.7.0)
      CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
      WORD_SIZE: 64
      LIBM: libopenlibm
      LLVM: libLLVM-11.0.1 (ORCJIT, haswell)
    Environment:
      JULIA_COPY_STACKS = 1
    
  4. mkitti commented on Oct 11, 2021

    @mkitti
    Member

    Perhaps this is a variation of a known issue:
    https://github.com/JuliaInterop/JavaCall.jl/blob/575f4514a1604c8c880667ee6e1398ecdf94647c/doc/faq.md#segault-on-osx

    Have you tried starting Julia with --handle-signals=no?

  5. KenziTrader commented on Oct 11, 2021

    @KenziTrader
    Author

    Yes, starting Julia 1.6.3 with --handle-signals=no works.

    Strange that in 1.6.2 the Segmentation fault doesn't cause Julia to crash but in 1.6.3 it does.

  6. mkitti commented on Oct 11, 2021

    @mkitti
    Member

    I suspect https://github.com/JuliaLang/julia/pull/40056/files may have affected this.

  7. changed the title [-]JavaCall segfaults on Julia 1.6.3[/-] [+]JavaCall crashes Julia 1.6.3 on macOS[/+] on Oct 11, 2021
  8. KenziTrader commented on Oct 11, 2021

    @KenziTrader
    Author

    But with --handle-signals=no I cannot stop my Pluto server anymore with Ctrl+C. I have to use kill -9.

  9. mkitti commented on Oct 11, 2021

    @mkitti
    Member

    I talked to @vtjnash on Slack and confirmed that JuliaLang/julia#40056 is at the heart of this change. We may be stuck until we implement signal chaining for Julia.

    As we wait for Julia to attempt to address this upstream, can you see if JavaCall.init("-Xrs") helps? -Xrs is the Java counter part to Julia's --handle-signals=no.

    https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE

  10. KenziTrader commented on Oct 11, 2021

    @KenziTrader
    Author

    Regretfully also JavaCall.init("-Xrs") crashes Julia 1.6.3 on MacOS.

  11. mkitti commented on Oct 11, 2021

    @mkitti
    Member

    Are you able to use any other version of Java?

    Another way to do this, might be starting Java first, and then Julia. In this case, we may be able to take advantage of Java's signal chaining. The main reason I'm asking about Java versions is that newer Java versions (16+) have a new incubating facility to call into native code ( https://docs.oracle.com/en/java/javase/16/docs/api/jdk.incubator.foreign/jdk/incubator/foreign/package-summary.html )

  12. KenziTrader commented on Oct 12, 2021

    @KenziTrader
    Author

    Also with Java SE 17 it crashes Julia with and without -Xrs.

    I don't know how to start Java first and then Julia.

    For the time being I'll start Julia with --handle-signals=no.

  13. ViralBShah commented on Nov 5, 2025

    @ViralBShah
    Member

    In CI, I see that with a recent Java and Julia version on OS X x86, this works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions