Clemapfel/Mousetrap.jl

hello world crashes on Ubuntu 22.04

ufechner7 opened this issue · 13 comments

julia> versioninfo()
Julia Version 1.9.2
Commit e4ee485e909 (2023-07-05 09:39 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen 9 7950X 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 1 on 32 virtual cores
Environment:
  LD_LIBRARY_PATH = /lib:/usr/lib:/usr/local/lib
(Mouse) pkg> st
Status `~/repos/Mouse/Project.toml`
  [5deeb4b9] mousetrap v0.1.0 `https://github.com/Clemapfel/mousetrap.jl#main`
  [7f2654e2] mousetrap_apple_jll v0.1.0+0 `https://github.com/Clemapfel/mousetrap_apple_jll#main`
  [b6bb2801] mousetrap_linux_jll v0.1.0+0 `https://github.com/Clemapfel/mousetrap_linux_jll#main`
  [1923bf96] mousetrap_windows_jll v0.1.0+0 `https://github.com/Clemapfel/mousetrap_windows_jll#main`
ufechner@ufryzen:~/repos/Mouse$ cat mouse.jl
using mousetrap
main() do app::Application
    window = Window(app)
    set_child!(window, Label("Hello World!"))
    present!(window)
end
julia> @time include("mouse.jl")

[20361] signal (11.1): Segmentation fault
in expression starting at /home/ufechner/repos/Mouse/mouse.jl:2
gdk_x11_surface_get_xid at /home/ufechner/.julia/artifacts/5498f875c31a1b3422ce1b64ef770407109eff30/lib/libgtk-4.so (unknown line)
Allocations: 1561196 (Pool: 1560438; Big: 758); GC: 2
Segmentation fault (core dumped)

Hi, I'm sorry you're having trouble. This seems to be an issue in the GTK4 back-end which is most likely a compatibility issues. What kind of device is this? Is this a regular machine or a virtual machine, also how many monitors do you have?

Please do

sudo apt-get update
sudo apt-get install gtk4
sudo apt-get upgrade

This will make sure that all the dependency and drivers are up to date, the crash is happening when trying to open a window using the X11 windowing system which isn't shipped with mousetrap, it comes pre-installed with ubuntu.

If the error still persist, please set the G_DEBUG environment variables to fatal-warnings using export G_DEBUG=fatal-warnings, then, in the same shell start the Julia process that crashes. This will hopefully give a bigger stacktrace.

export G_DEBUG=fatal-warnings
julia mouse.jl

You can also try changing the windowing system to wayland (click here to see how to do that), if the crash persists even on wayland then it may be a bigger issue.

Thank you

There is no gtk4 package for Ubuntu 22.04, at least not under this name:

ufechner@ufryzen:~$ sudo apt install gtk4
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package gtk4

This is a regular machine, I have one monitor.

I saw it here but I guess it is not available then, maybe libgtk-4-dev? I'm on fedora so I can't really test it. You can search for packages using apt-cache search gtk.

I did

sudo apt install libgtk-4-dev

which worked.
But the problem stays the same:

julia> include("mouse.jl")

[29115] signal (11.1): Segmentation fault
in expression starting at /home/ufechner/repos/Mouse/mouse.jl:2
gdk_x11_surface_get_xid at /home/ufechner/.julia/artifacts/5498f875c31a1b3422ce1b64ef770407109eff30/lib/libgtk-4.so (unknown line)
Allocations: 1551209 (Pool: 1550364; Big: 845); GC: 2
Segmentation fault (core dumped)

Same error if I run the tests in the package manager:

  [8e850ede] nghttp2_jll v1.48.0+0 `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll v17.4.0+0 `@stdlib/p7zip_jll`
        Info Packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ are restricted by compatibility constraints from upgrading.
     Testing Running tests...

[29233] signal (11.1): Segmentation fault
in expression starting at /home/ufechner/.julia/packages/mousetrap/FW8Qs/test/runtests.jl:2628
gdk_x11_surface_get_xid at /home/ufechner/.julia/artifacts/5498f875c31a1b3422ce1b64ef770407109eff30/lib/libgtk-4.so (unknown line)
Allocations: 2278768 (Pool: 2277446; Big: 1322); GC: 3
ERROR: Package mousetrap errored during testing (received signal: 11)

(Mouse) pkg> 

Did you also do the upgrade and setting the G_DEBUG environment variable?

Yes, I did.

Okay thank you, I don't think you can help me anymore then. I will try to reproduce this on my side asap so it can be fixed, this is a very critical bug

You could still try switching to wayland but it really should work on X11, even if that is a temporary fix this still needs to be addressed.

This is still not working for me, and I am not able to switch to Wayland (I guess due to the use of NVidia driver).

Could you reproduce the issue, e.g. by using a virtual machine with Ubuntu 22.04 and X11?

This is still not working for me. I mean, this issue is about Ubuntu 22.04 with X11, #20 is about Ubuntu 13.04 with Wayland.

ufechner@ubuntu22:~/repos/GUI$ julia --project
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using mousetrap
[ Info: Precompiling mousetrap [5deeb4b9-6e04-4da7-8b7f-c77fb1eae65e]

[5797] signal (11.128): Segmentation fault
in expression starting at /home/ufechner/.julia/packages/mousetrap/rYVpN/src/mousetrap.jl:29
_Z21implement_orientationRN5jlcxx6ModuleE at /home/ufechner/.julia/artifacts/1c1f06ce2383c6682f3e5ba47e220293a0dcac70/lib/libmousetrap_julia_binding.so (unknown line)
define_julia_module at /home/ufechner/.julia/artifacts/1c1f06ce2383c6682f3e5ba47e220293a0dcac70/lib/libmousetrap_julia_binding.so (unknown line)
register_julia_module at /home/ufechner/.julia/artifacts/88a033de19250acca6784647964d43d7121a06aa/lib/libcxxwrap_julia.so (unknown line)
register_julia_module at /home/ufechner/.julia/packages/CxxWrap/aXNBY/src/CxxWrap.jl:393 [inlined]
readmodule at /home/ufechner/.julia/packages/CxxWrap/aXNBY/src/CxxWrap.jl:742
wrapmodule at /home/ufechner/.julia/packages/CxxWrap/aXNBY/src/CxxWrap.jl:747
_jl_invoke at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/julia.h:1880 [inlined]
do_call at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:126
eval_value at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:226
eval_stmt_value at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:177 [inlined]
eval_body at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:624
jl_interpret_toplevel_thunk at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:762
jl_toplevel_eval_flex at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:912
jl_eval_module_expr at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:203 [inlined]
jl_toplevel_eval_flex at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:715
jl_eval_module_expr at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:203 [inlined]
jl_toplevel_eval_flex at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:715
jl_toplevel_eval_flex at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:856
ijl_toplevel_eval_in at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
include_string at ./loading.jl:1903
_jl_invoke at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2940
_include at ./loading.jl:1963
include at ./Base.jl:457 [inlined]
include_package_for_output at ./loading.jl:2049
jfptr_include_package_for_output_38844.clone_1 at /home/ufechner/packages/julias/julia-1.9/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/julia.h:1880 [inlined]
do_call at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:126
eval_value at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:226
eval_stmt_value at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:177 [inlined]
eval_body at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:624
jl_interpret_toplevel_thunk at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/interpreter.c:762
jl_toplevel_eval_flex at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:912
jl_toplevel_eval_flex at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:856
ijl_toplevel_eval_in at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/toplevel.c:971
eval at ./boot.jl:370 [inlined]
include_string at ./loading.jl:1903
include_string at ./loading.jl:1913 [inlined]
exec_options at ./client.jl:305
_start at ./client.jl:522
jfptr__start_40034.clone_1 at /home/ufechner/packages/julias/julia-1.9/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/julia.h:1880 [inlined]
true_main at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/jlapi.c:573
jl_repl_entrypoint at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/jlapi.c:717
main at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/cli/loader_exe.c:59
unknown function (ip: 0x7f6552429d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)
Allocations: 2998 (Pool: 2986; Big: 12); GC: 0
ERROR: Failed to precompile mousetrap [5deeb4b9-6e04-4da7-8b7f-c77fb1eae65e] to "/home/ufechner/.julia/compiled/v1.9/mousetrap/jl_dv2Nfq".
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
   @ Base ./loading.jl:2300
 [3] compilecache
   @ ./loading.jl:2167 [inlined]
 [4] _require(pkg::Base.PkgId, env::String)
   @ Base ./loading.jl:1805
 [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
   @ Base ./loading.jl:1660
 [6] macro expansion
   @ ./loading.jl:1648 [inlined]
 [7] macro expansion
   @ ./lock.jl:267 [inlined]
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1611

Three days and a fresh install of ubuntu on and old laptop of mine later, this is confirmed to be a down-stream issue of CxxWrap.jl, see JuliaInterop/CxxWrap.jl#372

Sadly this means I can't do anything to fix it, until their issue is resolved I have no way to make mousetrap work for ubuntu 22.04

Thanks for identifying the downstream issue! I will try to fix it or get it fixed.
By the way, I was born in Berlin...

@Clemapfel
I recommend trying this again with the just-released libcxxwrap-julia 0.11 and CxxWrap 0.14.

And it is not really solved yet, is it?

cf. JuliaInterop/CxxWrap.jl#372 (comment)

mousetrap v0.2 is done but still in testing, I'll push the new CxxWrap version along with it, which hopefully fixes the issue for you.