JuliaIO / JLD2.jl

HDF5-compatible file format in pure Julia
Other
553 stars 88 forks source link

Possible bug with version 0.4.42 #529

Closed JordiManyer closed 8 months ago

JordiManyer commented 8 months ago

Hello all!

I'm a dev in Gridap.jl, and I just got a weird error on our CI tests concerning a part of the code we have not touched in a long time. It fails when loading back a JLD2 file. The tests were passing just fine some hours ago, and the only difference I can notice in the setups is your recent update to 0.4.42.

I attach the tests that fail and those that passed some hours ago. I also attach our CI file if it can help.

Also for reference, the error itself:

  Got exception outside of a @test
  LoadError: UndefRefError: access to undefined reference
  Stacktrace:
    [1] fileio_load(f::FileIO.File{FileIO.DataFormat{:JLD2}, String}; nested::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
      @ JLD2 ~/.julia/packages/JLD2/8JZSz/src/fileio.jl:46
    [2] fileio_load(f::FileIO.File{FileIO.DataFormat{:JLD2}, String})
      @ JLD2 ~/.julia/packages/JLD2/8JZSz/src/fileio.jl:37
    [3] #invokelatest#2
      @ ./essentials.jl:819 [inlined]
    [4] invokelatest
      @ ./essentials.jl:816 [inlined]
    [5] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::FileIO.Formatted; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
      @ FileIO ~/.julia/packages/FileIO/jMf68/src/loadsave.jl:219

This happens in the following context:

d = mktempdir()
f = joinpath(d,"model.jld2")

to_jld2_file(model,f)
model2 == from_jld2_file(typeof(model),f)

where model is a julia struct and the load/save methods are defined as

function from_jld2_file(filename::AbstractString,dataset::AbstractString="data")
    load(filename)[dataset]
end
function to_jld2_file(object,filename::AbstractString,dataset::AbstractString="data")
    save(DataFormat{:JLD2}, filename, dataset, object)
end

Update:

I've managed to reproduce the error in local with JLD2.jl@0.4.42, and I've also confirmed that the error goes away by reverting to JLD2.jl@0.4.41. So it's definitely caused by the new release.

JonasIsensee commented 8 months ago

Hi @JordiManyer , thanks for reporting this! Something that would help me a lot would be the JLD2 file itself that fails to load.

JordiManyer commented 8 months ago

model.zip

Hi @JonasIsensee here is the file. Git did not allow me to upload the raw .jld2 file unfortunately. This is written with the failing version.

JonasIsensee commented 8 months ago

model.zip

Hi @JonasIsensee here is the file. Git did not allow me to upload the raw .jld2 file unfortunately. This is written with the failing version.

Thank you. Is it normal that UnstructuredDiscreteModel may contain #undef fields? ( in particular in dm.grid_topology.n_m_to_nface_to_mfaces)

With #530 this should work again.

JordiManyer commented 8 months ago

Yes, it is usual. That matrix basically contains the topological graph between entities of different dimension in the mesh. Each entry contains a possible dimensional combination (like nodes to nodes, cells to nodes, etc...). Most applications only require some of all the possible combinations to be computed. We compute them on-demand, and fill the matrix as needed.

JonasIsensee commented 8 months ago

v0.4.43 should be out in a bit.

JordiManyer commented 8 months ago

Everything is working now. Thank you!