[BUG] Segfault when connected through ssh without display
Details
plot causes segfault in Julia 1.6 and 1.7 if the julia session is through an SSH without display. Not sure if this is an upstream issue or not.
Error message in v1.6:
julia> using Plots
julia> plot(1:2)
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 (core dumped)
connect: Connection refused
GKS: can't connect to GKS socket application
signal (11): Segmentation fault
in expression starting at none:0
gks_drv_socket at /home/hacui/.julia/artifacts/b5fea2b0d5c84336f26b139587a84ee7e8ca2e12/lib/libGR.so (unknown line)
gks_ddlk.isra.0 at /home/hacui/.julia/artifacts/b5fea2b0d5c84336f26b139587a84ee7e8ca2e12/lib/libGR.so (unknown line)
gks_open_ws at /home/hacui/.julia/artifacts/b5fea2b0d5c84336f26b139587a84ee7e8ca2e12/lib/libGR.so (unknown line)
initgks at /home/hacui/.julia/artifacts/b5fea2b0d5c84336f26b139587a84ee7e8ca2e12/lib/libGR.so (unknown line)
gr_setcharheight at /home/hacui/.julia/artifacts/b5fea2b0d5c84336f26b139587a84ee7e8ca2e12/lib/libGR.so (unknown line)
setcharheight at /home/hacui/.julia/packages/GR/SOvTP/src/GR.jl:1651
unknown function (ip: 0x7f9e967e497f)
_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
#gr_set_font#390 at /home/hacui/.julia/packages/Plots/qbc7U/src/backends/gr.jl:408
gr_set_font##kw at /home/hacui/.julia/packages/Plots/qbc7U/src/backends/gr.jl:407
unknown function (ip: 0x7f9e967e409d)
_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
gr_set_tickfont at /home/hacui/.julia/packages/Plots/qbc7U/src/backends/gr.jl:678
_update_min_padding! at /home/hacui/.julia/packages/Plots/qbc7U/src/backends/gr.jl:890
_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
iterate at ./generator.jl:47 [inlined]
_collect at ./array.jl:695
unknown function (ip: 0x7f9e967c6ea5)
collect_similar at ./array.jl:606 [inlined]
map at ./abstractarray.jl:2294 [inlined]
_update_min_padding! at /home/hacui/.julia/packages/Plots/qbc7U/src/layouts.jl:290
_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
prepare_output at /home/hacui/.julia/packages/Plots/qbc7U/src/plot.jl:224
display at /home/hacui/.julia/packages/Plots/qbc7U/src/output.jl:147
_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
display at ./multimedia.jl:328
_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]
print_response at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:247
#40 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:231
jfptr_YY.40_18643 at /home/hacui/packages/julias/julia-1.6/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
with_repl_linfo at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
_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
print_response at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:229
do_respond at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:798
jfptr_do_respond_19057 at /home/hacui/packages/julias/julia-1.6/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_interface at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2441
jfptr_run_interface_20303 at /home/hacui/packages/julias/julia-1.6/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
run_frontend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1126
#44 at ./task.jl:411
jfptr_YY.44_18620 at /home/hacui/packages/julias/julia-1.6/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]
start_task at /buildworker/worker/package_linux64/build/src/task.c:834
Allocations: 27986524 (Pool: 27976941; Big: 9583); GC: 30
[1] 38962 segmentation fault (core dumped) julia-1.6
Backends
I only tested it with everything default.
This bug occurs on ( insert x below )
| Backend | yes | no | untested |
|---|---|---|---|
| gr (default) | x | ||
| pyplot | |||
| plotlyjs | |||
| pgfplotsx | |||
| unicodeplots | |||
| inspectdr | |||
| gaston |
Versions
Plots.jl version: 1.25.0
Backend version (]st -m <backend(s)>): GR: 0.62.1
Output of versioninfo():
Julia Version 1.6.4
Commit 35f0c911f4 (2021-11-19 03:54 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD Ryzen 9 5950X 16-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, generic)
Using headless mode:
$ ssh $USER@$HOST
$ GKSwstype=nul julia
julia> using Plots; plot(1:2)
# no gui window, use savefig/png instead
Using X Forwarding:
$ ssh -X $USER@$HOST
$ julia
julia> using Plots; plot(1:2)
# gui window
See https://gr-framework.org/workstations.html#no-output or https://discourse.julialang.org/t/what-does-gkswstype-do/59226.
Thank you for the fix. Currently, I start Julia REPL from the VS Code plug-in. It slows the plot in Code gracefully.
Maybe the segfault needs to be handled in a safe manner, and the issue can be closed.
Maybe the segfault needs to be handled in a safe manner
Agreed, this is known for a while, but that's a GR issue I guess ...
I'm not sure this should be closed. It would be reasonable for Plots to handle this segfault so that the user only sees an exception.
I'm not sure this should be closed. It would be reasonable for Plots to handle this segfault so that the user only sees an exception.
That would definitely be helpful from a user point of view.
Can you catch a segfault though?
Using Julia 1.10 and Plots 1.39 via SSH gave me the same error message excluding the segfault. The images produced looked odd: yticks labels were cut off partially, the xlabel was missing entirely. Using GKS_WSTYPE=nul julia lead to empty PDFs being produced, but GKS_WSTYPE=pdf julia did the trick for me.