JLD.jl
JLD.jl copied to clipboard
JLD.save crashes in 0.6.2, linux
My application is crashing on a JLD.save instruction in Julia 0.6.2 running in Linux. It works fine in Windows. Unfortunately, I have not been able create a MWE; so far every small example I've tried works OK. I also tried Pkg.update("JLD") and Pkg.test("JLD") with no errors, but I still get the crash in my code. Note: this problem is new since my sysadmin updated from 0.6.0 to 0.6.2. Here is the error message:
saving in:./checkpoint_ccsb_hessn_2.jld
typeof(hess_save) = Dict{Float64,SparseMatrixCSC{Float64,Int64}}
typeof(snr_save) = Array{Float64,1}
typeof(s0gap_save) = Array{Float64,1}
Error encountered while saving "/u4/vavasis/cohesive/conic_jl/checkpoint_ccsb_hessn_2.jld".
Fatal error:
ERROR: UndefVarError: save not defined
Stacktrace:
[1] #save#21(::Array{Any,1}, ::Function, ::FileIO.File{FileIO.DataFormat{:HDF5}}, ::String, ::Vararg{Any,N} where N) at /u4/vavasis/.julia/v0.6/FileIO/src/loadsave.jl:112
[2] save(::FileIO.File{FileIO.DataFormat{:HDF5}}, ::String, ::Dict{Float64,SparseMatrixCSC{Float64,Int64}}, ::String, ::Vararg{Any,N} where N) at /u4/vavasis/.julia/v0.6/FileIO/src/loadsave.jl:106
[3] #save#14(::Array{Any,1}, ::Function, ::String, ::String, ::Vararg{Any,N} where N) at /u4/vavasis/.julia/v0.6/FileIO/src/loadsave.jl:61
[4] maintimestepper(::Symbol, ::Int64, ::Int64, ::Int64, ::Array{conic_solve_cohesive.BulkMaterialModel,1}, ::Array{Set{Int64},1}, ::conic_solve_cohesive.IrrPiecewiseQuadraticInterfaceLaw, ::Array{Float64,1}, ::SparseMatrixCSC{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}, ::SparseMatrixCSC{Float64,Int64}, ::conic_solve_cohesive.CI_Handle0{conic_solve_cohesive.DeltansT6}, ::Array{conic_solve_cohesive.BCEntry,1}, ::Array{conic_solve_cohesive.BCEntry,1}, ::conic_solve_cohesive.BulkMesh{conic_solve_cohesive.MeshType_T6}, ::conic_solve_cohesive.BulkMeshAux, ::conic_solve_cohesive.DeltansT6, ::Array{Int64,2}, ::conic_solve_cohesive.InterfaceMeshAux, ::Array{Int64,1}, ::Array{Int64,1}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,2}, ::Array{Float64,2}, ::conic_solve_cohesive.ImplicitMidpointRule, ::conic_solve_cohesive.Params) at /u4/vavasis/cohesive/conic_jl/conic26.jl:5708
Here is the relevant source:
println("saving in:", hessn_fname(params, tind))
println("typeof(hess_save) = ", typeof(hess_save))
println("typeof(snr_save) = ", typeof(snr_save))
println("typeof(s0gap_save) = ", typeof(s0gap_save))
save(hessn_fname(params, tind), "hess_save", hess_save,
"snr_save", snr_save, "s0gap_save", s0gap_save)
Have you tried JLD2? That might work if JLD doesn't.
I was not able to install JLD2. I tried Pkg.add(JLD2) followed by Pkg.test(JLD2), which crashed (segmentation fault).
Can you submit an issue on the JLD2 repo with segfault and the steps to reproduce? In the meantime I'm not sure what to suggest in regards to the JLD issue. Hopefully someone else will chime in.
I finally got a chance to dig deeper into this issue by inserting many println statements into FileIO/src/loadsave.jl and FileIO/src/query.jl, and here is what I have found so far. It seems that the save routine is invoking query to determine the type of my JLD file, and sometimes query is returning HDF5 instead of JLD, thus crashing the save function.
Why is query returning HDF5 sometimes? It seems that query is actually calling open on the file with no arguments (i.e., open for read), even though my original call is save rather than load. And apparently the file is sitting in my folder but is corrupted (?) The issue seems to have gone away when I deleted the old file.
This seems like a bug! It is unexpected that JLD.save would try to open the file to determine whether it is really JLD.
Seeing the same error (on one machine but not the other) here when overwriting an existing file - deleting it fixed it for me as well.