jheinen / GR.jl

Plotting for Julia based on GR, a framework for visualisation applications
Other
356 stars 76 forks source link

Segfault when plotting on WSL2 #428

Closed korsbo closed 3 years ago

korsbo commented 3 years ago

Hi, I'm getting segfaults when I try to plot using GR (directly or via Plots.jl) on a Linux subsystem (WSL2, ubuntu) on Windows. I seem to get the same problem in both an external terminal and within VSCode. I tried nuking the .julia/compiled and .julia/artefacts folders but that did not help.

Any ideas on how I might fix this?

Thanks!

~/tmp/GR                                                                                               ⍉
▶ julia --project
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.1 (2021-04-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_PKG_SERVER = https://pumasai.juliahub.com

(GR) pkg> st --manifest
      Status `~/tmp/GR/Manifest.toml`
  [28b8d3ca] GR v0.58.1
  [cd3eb016] HTTP v0.9.13
  [83e8ac13] IniFile v0.5.0
  [692b3bcd] JLLWrappers v1.3.0
  [682c06a0] JSON v0.21.2
  [739be429] MbedTLS v1.0.3
  [69de0a69] Parsers v2.0.2
  [21216c6a] Preferences v1.2.2
  [5c2747f8] URIs v1.3.0
  [6e34b625] Bzip2_jll v1.0.6+5
  [83423d85] Cairo_jll v1.16.0+6
  [2e619515] Expat_jll v2.2.10+0
  [b22a6f82] FFMPEG_jll v4.3.1+4
  [a3f928ae] Fontconfig_jll v2.13.1+14
  [d7e528f0] FreeType2_jll v2.10.1+5
  [559328eb] FriBidi_jll v1.0.10+0
  [0656b61e] GLFW_jll v3.3.5+0
  [d2c73de3] GR_jll v0.58.1+0
  [78b55507] Gettext_jll v0.21.0+0
  [7746bdde] Glib_jll v2.68.3+0
  [aacddb02] JpegTurbo_jll v2.1.0+0
  [c1c5ebd0] LAME_jll v3.100.1+0
  [dd4b983a] LZO_jll v2.10.1+0
  [dd192d2f] LibVPX_jll v1.10.0+0
  [e9f186c6] Libffi_jll v3.2.2+0
  [d4300ac3] Libgcrypt_jll v1.8.7+0
  [7e76a0d4] Libglvnd_jll v1.3.0+3
  [7add5ba3] Libgpg_error_jll v1.42.0+0
  [94ce4f54] Libiconv_jll v1.16.1+1
  [4b2f31a3] Libmount_jll v2.35.0+0
  [89763e89] Libtiff_jll v4.3.0+0
  [38a345b3] Libuuid_jll v2.36.0+0
  [e7412a2a] Ogg_jll v1.3.5+0
  [458c3c95] OpenSSL_jll v1.1.10+0
  [91d4177d] Opus_jll v1.3.2+0
  [2f80f16e] PCRE_jll v8.44.0+0
  [30392449] Pixman_jll v0.40.1+0
  [ea2cea3b] Qt5Base_jll v5.15.3+0
  [a2964d1f] Wayland_jll v1.19.0+0
  [2381bf8a] Wayland_protocols_jll v1.18.0+4
  [02c8fc9c] XML2_jll v2.9.12+0
  [aed1982a] XSLT_jll v1.1.34+0
  [4f6342f7] Xorg_libX11_jll v1.6.9+4
  [0c0b7dd1] Xorg_libXau_jll v1.0.9+4
  [935fb764] Xorg_libXcursor_jll v1.2.0+4
  [a3789734] Xorg_libXdmcp_jll v1.1.3+4
  [1082639a] Xorg_libXext_jll v1.3.4+4
  [d091e8ba] Xorg_libXfixes_jll v5.0.3+4
  [a51aa0fd] Xorg_libXi_jll v1.7.10+4
  [d1454406] Xorg_libXinerama_jll v1.1.4+4
  [ec84b674] Xorg_libXrandr_jll v1.5.2+4
  [ea2f1a96] Xorg_libXrender_jll v0.9.10+4
  [14d82f49] Xorg_libpthread_stubs_jll v0.1.0+3
  [c7cfdc94] Xorg_libxcb_jll v1.13.0+3
  [cc61e674] Xorg_libxkbfile_jll v1.1.0+4
  [12413925] Xorg_xcb_util_image_jll v0.4.0+1
  [2def613f] Xorg_xcb_util_jll v0.4.0+1
  [975044d2] Xorg_xcb_util_keysyms_jll v0.4.0+1
  [0d47668e] Xorg_xcb_util_renderutil_jll v0.3.9+1
  [c22f9ab0] Xorg_xcb_util_wm_jll v0.4.1+1
  [35661453] Xorg_xkbcomp_jll v1.4.2+4
  [33bec58e] Xorg_xkeyboard_config_jll v2.27.0+4
  [c5fb5394] Xorg_xtrans_jll v1.4.0+3
  [3161d3a3] Zstd_jll v1.5.0+0
  [0ac62f75] libass_jll v0.14.0+4
  [f638f0a6] libfdk_aac_jll v0.1.6+4
  [b53b4c65] libpng_jll v1.6.38+0
  [f27f6e37] libvorbis_jll v1.3.7+0
  [1270edf5] x264_jll v2020.7.14+2
  [dfaa095f] x265_jll v3.0.0+3
  [d8fb68d0] xkbcommon_jll v0.9.1+5
  [0dad84c5] ArgTools
  [56f22d72] Artifacts
  [2a0f44e3] Base64
  [ade2ca70] Dates
  [8bb1440f] DelimitedFiles
  [f43a241f] Downloads
  [b77e0a4c] InteractiveUtils
  [b27032c2] LibCURL
  [76f85450] LibGit2
  [8f399da3] Libdl
  [37e2e46d] LinearAlgebra
  [56ddb016] Logging
  [d6f4376e] Markdown
  [a63ad114] Mmap
  [ca575930] NetworkOptions
  [44cfe95a] Pkg
  [de0858da] Printf
  [3fa0cd96] REPL
  [9a3f8284] Random
  [ea8e919c] SHA
  [9e88b42a] Serialization
  [6462fe0b] Sockets
  [fa267f1f] TOML
  [a4e569a6] Tar
  [8dfed614] Test
  [cf7118a7] UUIDs
  [4ec0a83e] Unicode
  [e66e0078] CompilerSupportLibraries_jll
  [deac9b47] LibCURL_jll
  [29816b5a] LibSSH2_jll
  [c8ffd9c3] MbedTLS_jll
  [14a3606d] MozillaCACerts_jll
  [83775a58] Zlib_jll
  [8e850ede] nghttp2_jll
  [3f19e933] p7zip_jll

julia> using GR

julia> plot([1,2,3])
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, minimal, offscreen, vnc, xcb.

Aborted
connect: Connection refused
GKS: can't connect to GKS socket application

signal (11): Segmentation fault
in expression starting at REPL[4]:1
gks_drv_socket at /home/niklas/.julia/artifacts/1fbc5d63ee59773d2832c0f9beac7d1116b27291/lib/libGR.so (unknown line)
gks_ddlk.isra.0 at /home/niklas/.julia/artifacts/1fbc5d63ee59773d2832c0f9beac7d1116b27291/lib/libGR.so (unknown line)
gks_open_ws at /home/niklas/.julia/artifacts/1fbc5d63ee59773d2832c0f9beac7d1116b27291/lib/libGR.so (unknown line)
initgks at /home/niklas/.julia/artifacts/1fbc5d63ee59773d2832c0f9beac7d1116b27291/lib/libGR.so (unknown line)
gr_clearws at /home/niklas/.julia/artifacts/1fbc5d63ee59773d2832c0f9beac7d1116b27291/lib/libGR.so (unknown line)
clearws at /home/niklas/.julia/packages/GR/bVi3d/src/GR.jl:664 [inlined]
plot_data at /home/niklas/.julia/packages/GR/bVi3d/src/jlgr.jl:1206
plot_data at /home/niklas/.julia/packages/GR/bVi3d/src/jlgr.jl:1183 [inlined]
#plot#42 at /home/niklas/.julia/packages/GR/bVi3d/src/jlgr.jl:1739
plot at /home/niklas/.julia/packages/GR/bVi3d/src/jlgr.jl:1731
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:115
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:204
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:155 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:562
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:670
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:877
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:825
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:825
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:929
eval at ./boot.jl:360 [inlined]
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
repl_backend_loop at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
start_repl_backend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
#run_repl#42 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
run_repl at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
#874 at ./client.jl:387
jfptr_YY.874_41532.clone_1 at /home/niklas/software/julia-1.6.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:714
#invokelatest#2 at ./essentials.jl:708 [inlined]
invokelatest at ./essentials.jl:706 [inlined]
run_main_repl at ./client.jl:372
exec_options at ./client.jl:302
_start at ./client.jl:485
jfptr__start_34289.clone_1 at /home/niklas/software/julia-1.6.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2237 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2419
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1703 [inlined]
true_main at /buildworker/worker/package_linux64/build/src/jlapi.c:560
repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:702
main at julia (unknown line)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4007d8)
Allocations: 17565393 (Pool: 17559799; Big: 5594); GC: 24
[1]    485 segmentation fault  julia --project
korsbo commented 3 years ago

I should add that this used to work just fine (at least in VSCode) but it broke a couple of weeks ago and I don't quite know what caused it to break.

IngoMeyer441 commented 3 years ago

Hey @korsbo and @DNF2, how did you set up GR.jl in VSCode before? Do other graphical applications (like vlc) work in WSL2? I am not sure, but I suppose that the Qt libraries are missing and they are not shipped with the GR binaries.

IngoMeyer441 commented 3 years ago

Ok, I can reproduce the problem on Windows 10 21H1, with Ubuntu in WSL2 and Julia 1.6.2. Installing Qt5 libraries does not help. This probably needs some deeper debugging.

korsbo commented 3 years ago

A long-ish time ago, I was using an X-server on windows that I forwarded stuff to in order to get plots, etc, working. For the last year or so though, I've been using VSCode and everything seems to have been taken care of for me. I don't know what magic this entailed but I no longer needed to set anything up to get graphics working.

I have now tried to update/rebuild GR on a real windows version of Julia too (no WSL), hoping that this would set things up correctly, but without success. Plotting works on windows but still not on WSL2.

jheinen commented 3 years ago

... but without success. Plotting works on windows ...

Using GR with the native Julia (1.6.2) version should work out of the box. What do you mean with "no success" vs. "Plotting works on Windows"?

korsbo commented 3 years ago

My primary dev environment is on my WSL2 Ubuntu subsystem, running a Linux kernel under Windows. That's where I get the segfaults.

Just to pin down the error better, I also installed Julia straight under Windows, without being in the WSL subsystem. There, GR works just fine but I instead loose out of alot of the benefits that a Linux kernel provides.

IngoMeyer441 commented 3 years ago

Seems like GUI support is still only available in Windows preview versions (WSLg): https://devblogs.microsoft.com/commandline/the-initial-preview-of-gui-app-support-is-now-available-for-the-windows-subsystem-for-linux-2/ You probably used Xming before?

baggepinnen commented 3 years ago

I seem to get the same problem on github actions https://github.com/baggepinnen/ControlSystemIdentification.jl/runs/3387766476?check_suite_focus=true#step:4:1375

IngoMeyer441 commented 3 years ago

After installing VcXsrv I get this result:

image

I tried Xming first, but it does not work with recent Qt versions.

So, I needed these steps to succeed:

  1. Install VcXsrv on Windows 10
  2. Start VcXsrv with the included XLaunch application and disable access control
  3. Start WSL and set the correct DISPLAY variable:
    export DISPLAY="$(route.exe print | grep '\b0.0.0.0\b' | awk '{ print $4 }'):0.0"
  4. Start julia und use GR :slightly_smiling_face:
IngoMeyer441 commented 3 years ago

@baggepinnen In a CI pipeline, it is probably better to use another output format. You can set

export GKS_WSTYPE=png

to produce a PNG file instead (gks.png), but other types are also possible (for example PDF for vector graphics). Use GKS_FILEPATH to set another filename.

korsbo commented 3 years ago

I think that @IngoMeyer441's solution is pretty spot-on, thank you!. I Also found a simple VSCode-specific solution that does not require running an X-server. Setting "julia.usePlotPane": true got everything working again.

I think that the perplexing bit of my issue was that plotting used to work in VSCode until I somehow managed to disable usePlotPane. When that happened, the plotting reverted back to trying to open an external plot - something I had not enabled support for. Since plotting then failed both on VSCode and in a separate REPL (which presumably never worked, I had just not tried it) I did not identify the issue as a VSCode issue.

So, problem solved. Thanks for your help and for your work on the lovely GR.jl package!