Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Plots crashes and julia hangs plotting correlogram with >11 columns on Boston housing dataset #4856

Closed
smartinsightsfromdata opened this issue Dec 26, 2023 · 8 comments
Labels

Comments

@smartinsightsfromdata
Copy link

smartinsightsfromdata commented Dec 26, 2023

With following code Plots.jl crashes and julia hangs. Julia 1.9.4 on Ubuntu 23.04 + vscode.
The Boston housing dataset is very common and similar visualizations exist e.g. with Seaborn on Python and many packages in R.
Everything works with 11 variables / columns but crashes with >11. As there are no problems in plotly, it may well be that the problem is centred on the gr() backend.

using DataFrames, Plots
using MLDatasets: BostonHousing

dataset = BostonHousing()
df = dataset.features;

df = df[:,1:12];

function correlogram(df)
    rows = cols = size(df,2)
    plots = []
    for row = 1:rows, col = 1:cols
        if row == col
            push!(
                plots,
                histogram(df[:,row],bins=10, xtickfont = font(5), ytickfont = font(5), legend = false))
        else
            push!(
                plots,
                scatter(df[:,row], df[:,col], xtickfont = font(5), ytickfont = font(5), legend = false, markersize=1, alpha = 0.3, smooth = true,
                linewidth=3, linecolor=:red),
            )
        end
    end
    plot(plots..., size=(1200, 1000), layout = (rows, cols))
end

correlogram(df)

Before dying julia display the following:

free(): invalid next size (normal)

[760418] signal (6.-6): Aborted
in expression starting at none:0

Please note that not surprisingly the problem exist with StatsPlots (where I originally found the issue). I reported here JuliaPlots/StatsPlots.jl#547 (but the error shown before hanging is slightly different).

Backends

I use gr()

This bug occurs on ( insert x below )

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

Versions

Plots.jl version: Plots v1.39.0
Backend version (]st -m <backend(s)>): GR v0.72.8
Output of versioninfo():
julia> versioninfo()
Julia Version 1.9.4
Commit 8e5136fa297 (2023-11-14 08:46 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
Threads: 12 on 12 virtual cores
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS = 12

@smartinsightsfromdata smartinsightsfromdata changed the title [BUG] Plots crashes and julia hangs plotting correlogram with >12 columns on Boston housing dataset [BUG] Plots crashes and julia hangs plotting correlogram with >11 columns on Boston housing dataset Dec 27, 2023
@BioTurboNick
Copy link
Member

BioTurboNick commented Jan 11, 2024

FWIW, it works for me on Julia 1.10 with a point update to GR from the one you ran:
image

[a93c6f00] DataFrames v1.6.1
[28b8d3ca] GR v0.72.9
[eb30cadb] MLDatasets v0.7.14
[91a5bcdd] Plots v1.39.0

Julia Version 1.10.0
Commit 3120989f39 (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 12 × Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 12 virtual cores

Also works on Julia 1.9.4 for me.

Downgrading GR to 0.72.8 and it still works. Maybe it's a Linux thing. Any way you can narrow down exactly when the crash occurs? during the loop? Was there a stack trace?

@smartinsightsfromdata
Copy link
Author

It seems the issue is with VSCODE: I was able to make it work in the REPL.

I do find it peculiar that works with plotly backend though.

I will close this issue here and open it in https://github.com/julia-vscode/julia-vscode

@smartinsightsfromdata
Copy link
Author

smartinsightsfromdata commented Jan 17, 2024

@BioTurboNick By the way, the same gr() code crashes in jupyterlab but NOT with plotly() backend. Not sure where to report this...

From initial responses it seems that the VSCODE for Julia people won't do anything. It would be great if you guys could have a better look at this issue...

@BioTurboNick
Copy link
Member

BioTurboNick commented Jan 17, 2024

It could be a GR issue then, with certain display types? Honestly if there are malloc/free issues, it is probably something in GR's C internals, rather than in Julia.

@jheinen
Copy link
Member

jheinen commented Jan 20, 2024

The problem only occurs in the GR SVG output driver. As a temporary workaround, please use PNG output in GUI environments (VScode, Jupyter, JupyterLab, Pluto) . I hope we can fix the problem with the next GR release.

@jheinen jheinen reopened this Jan 20, 2024
@jheinen
Copy link
Member

jheinen commented Jan 23, 2024

The problem is fixed with this commit. A new GR release is expected in the next days.

@smartinsightsfromdata
Copy link
Author

@BeastyBlacksmith what is the plan for the next release of Plots.jl?

I understand that the new version of GR.jl https://github.com/jheinen/GR.jl/releases/tag/v0.73.2 has the fix for this issue, but it is currently not compatible...

@BeastyBlacksmith
Copy link
Member

Plots 1.40 is compatible with GR 0.73 which includes 0.73.2, c.f.

GR = "0.69.5 - 0.73"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants