JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.83k stars 353 forks source link

[BUG] Segmentation fault on GR when label is too long #4198

Closed st-- closed 2 years ago

st-- commented 2 years ago

Details

julia> using Plots

julia> plot(1:5; label="x"^257)  # works

julia> plot(1:5; label="x"^258)  # crashes:

signal (11): Segmentation fault
in expression starting at none:0
unknown function (ip: 0x3300000037)
Allocations: 24525402 (Pool: 24516509; Big: 8893); GC: 27
fish: “julia --project=.” terminated by signal SIGSEGV (Address boundary error)

or some other error message, sometimes I got

*** stack smashing detected ***: terminated

signal (6): Aborted
in expression starting at none:0
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7fbe921f829d)
__fortify_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
__stack_chk_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
process_glyphs at /u/10/johnt1/unix/.julia/packages/GR/TqJvH/src/../deps/gr/lib/libGR.so (unknown line)
gks_inq_text_extent at /u/10/johnt1/unix/.julia/packages/GR/TqJvH/src/../deps/gr/lib/libGR.so (unknown line)
gr_inqtext at /u/10/johnt1/unix/.julia/packages/GR/TqJvH/src/../deps/gr/lib/libGR.so (unknown line)
inqtext at /u/10/johnt1/unix/.julia/packages/GR/TqJvH/src/GR.jl:820
unknown function (ip: 0x7fbe36a8caa8)
gr_inqtext at /u/10/johnt1/unix/.julia/packages/Plots/dNEbX/src/backends/gr.jl:235
unknown function (ip: 0x7fbe36a8a668)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
gr_get_legend_geometry at /u/10/johnt1/unix/.julia/packages/Plots/dNEbX/src/backends/gr.jl:1263
gr_display at /u/10/johnt1/unix/.julia/packages/Plots/dNEbX/src/backends/gr.jl:981
unknown function (ip: 0x7fbe16fa052b)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
gr_display at /u/10/johnt1/unix/.julia/packages/Plots/dNEbX/src/backends/gr.jl:670
gr_display at /u/10/johnt1/unix/.julia/packages/Plots/dNEbX/src/backends/gr.jl:636 [inlined]
_display at /u/10/johnt1/unix/.julia/packages/Plots/dNEbX/src/backends/gr.jl:2199
display at /u/10/johnt1/unix/.julia/packages/Plots/dNEbX/src/output.jl:146
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
display at ./multimedia.jl:328
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
#invokelatest#2 at ./essentials.jl:716 [inlined]
invokelatest at ./essentials.jl:714 [inlined]
print_response at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:291
#45 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:275
jfptr_YY.45_47521.clone_1 at /u/10/johnt1/unix/Software/julia-1.7.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
with_repl_linfo at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:508
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
print_response at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:273
do_respond at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:844
jfptr_do_respond_47485.clone_1 at /u/10/johnt1/unix/Software/julia-1.7.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
#invokelatest#2 at ./essentials.jl:716 [inlined]
invokelatest at ./essentials.jl:714 [inlined]
run_interface at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2493
jfptr_run_interface_46795.clone_1 at /u/10/johnt1/unix/Software/julia-1.7.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
run_frontend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:1230
#49 at ./task.jl:423
jfptr_YY.49_47524.clone_1 at /u/10/johnt1/unix/Software/julia-1.7.1/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:877
Allocations: 35534411 (Pool: 35518259; Big: 16152); GC: 41
fish: “julia --project=.” terminated by signal SIGABRT (Abort)

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pyplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version: Backend version (]st -m <backend(s)>): [91a5bcdd] Plots v1.27.5 [28b8d3ca] GR v0.64.2

Output of versioninfo():

Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, tigerlake)
jheinen commented 2 years ago

The problem is fixed in GR 0.64.3.

BeastyBlacksmith commented 2 years ago

This still segfaults for plot(1:5; label="x"^3000)

jheinen commented 2 years ago

Strange: in plain GR, I get an error:

using GR
plot(1:5; title="x"^3000)
GKS: String is too long in routine TEXT
BeastyBlacksmith commented 2 years ago

In GR you can try

using GR
legend("x"^3000)
plot(1:5)
jheinen commented 2 years ago

I fixed the problem in the GR development branch, but the behaviour would be the same: error message GKS: String is too long in routine TEXT, no output