Code Monkey home page Code Monkey logo

jld2.jl's Introduction

JLD2

Documentation Tests CodeCov Downloads
CI codecov.io JLD2 Downloads

JLD2 saves and loads Julia data structures in a format comprising a subset of HDF5, without any dependency on the HDF5 C library. JLD2 is able to read most HDF5 files created by other HDF5 implementations supporting HDF5 File Format Specification Version 3.0 (i.e. libhdf5 1.10 or later) and similarly those should be able to read the files that JLD2 produces. JLD2 provides read-only support for files created with the JLD package.

Reading and writing data

save and load functions

The save and load functions, provided by FileIO, provide a mechanism to read and write data from a JLD2 file. To use these functions, you may either write using FileIO or using JLD2. FileIO will determine the correct package automatically.

The save function accepts an AbstractDict yielding the key/value pairs, where the key is a string representing the name of the dataset and the value represents its contents:

using FileIO
save("example.jld2", Dict("hello" => "world", "foo" => :bar))

The save function can also accept the dataset names and contents as arguments:

save("example.jld2", "hello", "world", "foo", :bar)

When using the save function, the file extension must be .jld2, since the extension .jld currently belongs to the previous JLD package.

If called with a filename argument only, the load function loads all datasets from the given file into a Dict:

load("example.jld2") # -> Dict{String,Any}("hello" => "world", "foo" => :bar)

If called with a single dataset name, load returns the contents of that dataset from the file:

load("example.jld2", "hello") # -> "world"

If called with multiple dataset names, load returns the contents of the given datasets as a tuple:

load("example.jld2", "hello", "foo") # -> ("world", :bar)

A new interface: jldsave

jldsave makes use of julia's keyword argument syntax to store files, thus leveraging the parser and not having to rely on macros. The new interface can be imported with using JLD2. To use it, write

using JLD2

x = 1
y = 2
z = 42

# The simplest case:
jldsave("example.jld2"; x, y, z)
# it is equivalent to 
jldsave("example.jld2"; x=x, y=y, z=z)

# You can assign new names selectively
jldsave("example.jld2"; x, a=y, z)

# and if you want to confuse your future self and everyone else, do
jldsave("example.jld2"; z=x, x=y, y=z)

In the above examples, ; after the filename is important. Compression and non-default IO types may be set via positional arguments like:

jldopen("example.jld2", "w"; compress = true) do f
    f["large_array"] = zeros(10000)
end

File interface

It is also possible to interact with JLD2 files using a file-like interface. The jldopen function accepts a file name and an argument specifying how the file should be opened:

using JLD2

f = jldopen("example.jld2", "r")  # open read-only (default)
f = jldopen("example.jld2", "r+") # open read/write, failing if no file exists
f = jldopen("example.jld2", "w")  # open read/write, overwriting existing file
f = jldopen("example.jld2", "a+") # open read/write, preserving contents of existing file or creating a new file

Data can be written to the file using write(f, "name", data) or f["name"] = data, or read from the file using read(f, "name") or f["name"]. When you are done with the file, remember to call close(f).

Like open, jldopen also accepts a function as the first argument, permitting do-block syntax:

jldopen("example.jld2", "w") do file
    file["bigdata"] = randn(5)
end

Groups

It is possible to construct groups within a JLD2 file, which may or may not be useful for organizing your data. You can create groups explicitly:

jldopen("example.jld2", "w") do file
    mygroup = JLD2.Group(file, "mygroup")
    mygroup["mystuff"] = 42
end

or implicitly, by saving a variable with a name containing slashes as path delimiters:

jldopen("example.jld2", "w") do file
    file["mygroup/mystuff"] = 42
end
# or save("example.jld2", "mygroup/mystuff", 42)

Both of these examples yield the same group structure, which you can see at the REPL:

julia> file = jldopen("example.jld2", "r")
JLDFile /Users/simon/example.jld2 (read-only)
 โ””โ”€๐Ÿ“‚ mygroup
    โ””โ”€๐Ÿ”ข mystuff

Similarly, you can access groups directly:

jldopen("example.jld2", "r") do file
    @assert file["mygroup"]["mystuff"] == 42
end

or using slashes as path delimiters:

@assert load("example.jld2", "mygroup/mystuff") == 42

When loading files with nested groups these will be unrolled into paths by default but yield nested dictionaries but with the nested keyword argument.

load("example.jld2") # -> Dict("mygroup/mystuff" => 42)
load("example.jld2"; nested=true) # -> Dict("mygroup" => Dict("mystuff" => 42))

Custom Serialization

The API is simple enough, to enable custom serialization for your type A you define a new type e.g. ASerialization that contains the fields you want to store and define JLD2.writeas(::Type{A}) = ASerialization. Internally JLD2 will call Base.convert when writing and loading, so you need to make sure to extend that for your type.

struct A
    x::Int
end

struct ASerialization
    x::Vector{Int}
end

JLD2.writeas(::Type{A}) = ASerialization
Base.convert(::Type{ASerialization}, a::A) = ASerialization([a.x])
Base.convert(::Type{A}, a::ASerialization) = A(only(a.x))

If you do not want to overload Base.convert then you can also define

JLD2.wconvert(::Type{ASerialization}, a::A) = ASerialization([a.x])
JLD2.rconvert(::Type{A}, a::ASerialization) = A(only(a.x))

instead. This may be particularly relevant when types are involved that are not your own.

struct B
    x::Float64
end

JLD2.writeas(::Type{B}) = Float64
JLD2.wconvert(::Type{Float64}, b::B) = b.x
JLD2.rconvert(::Type{B}, x::Float64) = B(x)

arr = [B(rand()) for i=1:10]

jldsave("test.jld2"; arr)

In this example JLD2 converts the array of B structs to a plain Vector{Float64} prior to storing to disk.

Unpack.jl API

When additionally loading the UnPack.jl package, its @unpack and @pack! macros can be used to quickly save and load data from the file-like interface. Example:

using UnPack
file = jldopen("example.jld2", "w")
x, y = rand(2)

@pack! file = x, y # equivalent to file["x"] = x; file["y"] = y
@unpack x, y = file # equivalent to x = file["x"]; y = file["y"]

The group file_group = Group(file, "mygroup") can be accessed with the same file-like interface as the "full" struct.

jld2.jl's People

Contributors

ararslan avatar chrisrackauckas avatar dependabot[bot] avatar dilumaluthge avatar dylanfesta avatar fredrikekre avatar gdkrmr avatar giordano avatar github-actions[bot] avatar goggle avatar grero avatar jeffbezanson avatar johnnychen94 avatar jonasisensee avatar jw3126 avatar keno avatar kmsquire avatar lhupe avatar ranocha avatar rdeits avatar simonster avatar sjkelly avatar staticfloat avatar thchr avatar thisrod avatar timholy avatar tkelman avatar viralbshah avatar vtjnash avatar yingboma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jld2.jl's Issues

Thoughts on addrequire?

JLD supports addrequire to allow folks to ensure that necessary packages are loaded before objects from a JLD file. If you'd support this, I will eventually get around to submitting a PR.

Inexact error

Hello,
I have found bug (probably overflow) when saving large array of strings.
The error can be replicated as

save("/dev/shm/test.jld2","df",fill("a",100000));

which returns

ERROR: InexactError()
Stacktrace:
[1] write_heap_object(::JLD2.JLDFile{JLD2.MmapIO}, ::Type{T} where T, ::Array{UInt8,1}, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/ubuntu/.julia/v0.6/JLD2/src/global_heaps.jl:70
[2] store_vlen! at /home/ubuntu/.julia/v0.6/JLD2/src/data.jl:678 [inlined]
[3] h5convert!(::JLD2.IndirectPointer, ::Type{JLD2.Vlen{String}}, ::JLD2.JLDFile{JLD2.MmapIO}, ::String, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/ubuntu/.julia/v0.6/JLD2/src/data.jl:753
[4] write_data(::JLD2.MmapIO, ::JLD2.JLDFile{JLD2.MmapIO}, ::Array{String,1}, ::Type{JLD2.Vlen{String}}, ::JLD2.HasReferences, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/ubuntu/.julia/v0.6/JLD2/src/dataio.jl:178
[5] write_dataset(::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.WriteDataspace{1,Tuple{}}, ::JLD2.VariableLengthDatatype{JLD2.FixedPointDatatype}, ::Type{JLD2.Vlen{String}}, ::Array{String,1}, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/ubuntu/.julia/v0.6/JLD2/src/datasets.jl:401
[6] write(::JLD2.Group{JLD2.JLDFile{JLD2.MmapIO}}, ::String, ::Array{String,1}, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/ubuntu/.julia/v0.6/JLD2/src/groups.jl:119
[7] (::JLD2.##38#39{String,Array{String,1},Tuple{}})(::JLD2.JLDFile{JLD2.MmapIO}) at /home/ubuntu/.julia/v0.6/JLD2/src/loadsave.jl:103
[8] #jldopen#29(::Array{Any,1}, ::Function, ::JLD2.##38#39{String,Array{String,1},Tuple{}}, ::String, ::Vararg{String,N} where N) at /home/ubuntu/.julia/v0.6/JLD2/src/loadsave.jl:4
[9] #save#37(::Array{Any,1}, ::Function, ::FileIO.File{FileIO.DataFormat{:JLD2}}, ::String, ::Array{String,1}) at /home/ubuntu/.julia/v0.6/JLD2/src/loadsave.jl:101
[10] save(::FileIO.File{FileIO.DataFormat{:JLD2}}, ::String, ::Array{String,1}) at /home/ubuntu/.julia/v0.6/JLD2/src/loadsave.jl:98
[11] #save#14(::Array{Any,1}, ::Function, ::String, ::String, ::Vararg{Any,N} where N) at /home/ubuntu/.julia/v0.6/FileIO/src/loadsave.jl:61
[12] save(::String, ::String, ::Array{String,1}) at /home/ubuntu/.julia/v0.6/FileIO/src/loadsave.jl:61

Thanks for addressing this.

recommended testing protocol

The readme cautions that the package

has received little testing in the wild

I would like to help by testing on data I work with, and I am wondering what the recommended testing protocol is. My first-pass approach would be to write, read, and compare, but what's the recommended comparison operator that I should use? iseq from the unit tests?

Option to allow reconstructing mutable struct

I would like to save a mutable struct then restore it later mutable. I'd like the restore to be anonymous. How could I make it mutable without explicitly redefining the struct in the target code?

mutable struct Point
  x
  y
end
p = Point(1,2)
using FileIO
save("point.jld2", Dict("p"=>p))

# open a new julia
using FileIO
p = load("point.jld2", "p")
  # WARNING: type Point does not exist in workspace; reconstructing
p.x
p.y = 3
  # ERROR: type ##Point#661 is immutable

problem with JLD2.save

I have a problem with the JLD.save as follows

using JLD2
x = x[1]
JLD2.save("test.jld2","x",x)

according to docs, this should work, but I am having error

ERROR: MethodError: no method matching save(::String, ::String, ::Array{Int64,1})
Closest candidates are:
save(::FileIO.File{FileIO.DataFormat{:JLD2}}, ::AbstractString, ::Any, ::Any...; kwargs...) at >/Users/tpevny/.julia/v0.6/JLD2/src/loadsave.jl:98
save(::FileIO.File{FileIO.DataFormat{:JLD2}}, ::Any...; kwargs...) at >/Users/tpevny/.julia/v0.6/JLD2/src/loadsave.jl:110

Thanks for help

Undefined "unshift!"

Probably after some package update I can't load JLD2 anymore. This is the error I'm getting after using JLD2:

WARNING: both DataStructures and Base export "unshift!"; uses of it in module JLD2 must be qualified
ERROR: LoadError: UndefVarError: unshift! not defined
Stacktrace:
 [1] define_packed(::DataType) at /Users/karrasch/.julia/v0.6/JLD2/src/misc.jl:10
 [2] include_from_node1(::String) at ./loading.jl:576
 [3] include(::String) at ./sysimg.jl:14
 [4] anonymous at ./<missing>:2
while loading /Users/karrasch/.julia/v0.6/JLD2/src/JLD2.jl, in expression starting on line 46
ERROR: Failed to precompile JLD2 to /Users/karrasch/.julia/lib/v0.6/JLD2.ji.
Stacktrace:
 [1] compilecache(::String) at ./loading.jl:710
 [2] _require(::Symbol) at ./loading.jl:497
 [3] require(::Symbol) at ./loading.jl:405
 [4] macro expansion at /Users/karrasch/.julia/v0.6/Atom/src/repl.jl:118 [inlined]
 [5] anonymous at ./<missing>:?

Is it just that unshift! should be qualified in that one line? Or is it something deeper?

package test not running in 0.7.0-alpha

In Windows 10, Julia 0.7.0-alpha, I was able to execute Pkg.add("JLD2"), but Pkg.test("JLD2") gave me the following error (after many deprecation warnings):

ERROR: LoadError: LoadError: syntax: local variable name "x" conflicts with an argument
Stacktrace:
 [1] include at .\boot.jl:314 [inlined]
 [2] include_relative(::Module, ::String) at .\loading.jl:1071
 [3] include(::Module, ::String) at .\sysimg.jl:29
 [4] include(::String) at C:\Users\vavasis\.julia\packages\JLD2\6s4K\src\JLD2.jl:3
 [5] top-level scope
 [6] include at .\boot.jl:314 [inlined]
 [7] include_relative(::Module, ::String) at .\loading.jl:1071
 [8] include(::Module, ::String) at .\sysimg.jl:29
 [9] top-level scope
 [10] eval at .\boot.jl:316 [inlined]
 [11] eval(::Expr) at .\client.jl:394
 [12] macro expansion at .\none:3 [inlined]
 [13] top-level scope at .\<missing>:0
in expression starting at C:\Users\vavasis\.julia\packages\JLD2\6s4K\src\dataspaces.jl:47
in expression starting at C:\Users\vavasis\.julia\packages\JLD2\6s4K\src\JLD2.jl:426

Recent failures with byte alignment

ERROR: LoadError: ArgumentError: reinterpret from alignment 1 bytes to alignment 4 bytes not allowed
Stacktrace:
 [1] reinterpret(::Type{UInt32}, ::Array{UInt8,1}, ::Tuple{Int64}) at ./array.jl:160
 [2] reinterpret(::Type{UInt32}, ::Array{UInt8,1}) at ./array.jl:139
 [3] include_from_node1(::String) at ./loading.jl:551
 [4] include(::String) at ./sysimg.jl:14
 [5] anonymous at ./<missing>:2
while loading /Users/seth/.julia/v0.7/JLD2/src/JLD2.jl, in expression starting on line 6

This appears to be all over the place via

const OBJECT_HEADER_SIGNATURE = reinterpret(UInt32, UInt8['O', 'H', 'D', 'R'])[1]
julia> versioninfo()
Julia Version 0.7.0-DEV.373
Commit 82e9638225 (2017-05-28 01:51 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin16.5.0)
  CPU: Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, skylake)

New release?

Would you be willing to tag a new release sometime soon? It would be nice to have the new get() methods and the 0.7 fixes in a tagged version.

@load should provide better error message when symbol is passed without variable names

julia>   using JLD2,FileIO

julia>   data = 1
1

julia>   fn = "data.jld2"
"data.jld2"

julia>   JLD2.@save fn data

julia>   JLD2.@load fn
ERROR: MethodError: no method matching jldopen(::Symbol)
Closest candidates are:
  jldopen(::AbstractString) at /home/phuoc/.julia/v0.6/JLD2/src/JLD2.jl:286
  jldopen(::AbstractString, ::Bool, ::Bool, ::Bool) at /home/phuoc/.julia/v0.6/JLD2/src/JLD2.jl:201
  jldopen(::AbstractString, ::Bool, ::Bool, ::Bool, ::T<:Union{Type{IOStream}, Type{JLD2.MmapIO}}; compress, mmaparrays) where T<:Union{Type{IOStream}, Type{JLD2.MmapIO}} at /home/phuoc/.julia/v0.6/JLD2/src/JLD2.jl:201
  ...

ERROR: SystemError: truncate: Invalid argument

Encountered the following error when trying to close a file:

`julia> fjld["CENSUS_YEAR/year"]=testVar
48336073-element Array{Any,1}:
 "GEO_CODE (POR)"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 โ‹ฎ
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"
 "2016"

julia> close(fjld)
ERROR: SystemError: truncate: Invalid argument
Stacktrace:
 [1] #systemerror#44 at .\error.jl:64 [inlined]
 [2] systemerror(::String, ::Bool) at .\error.jl:64
 [3] truncate(::IOStream, ::Int64) at .\iostream.jl:43
 [4] truncate_and_close(::JLD2.MmapIO, ::Int64) at C:\Users\sdmca\.julia\v0.6\JLD2\src\mmapio.jl:164
 [5] close(::JLD2.JLDFile{JLD2.MmapIO}) at C:\Users\sdmca\.julia\v0.6\JLD2\src\JLD2.jl:364`

System info:
Julia Version 0.6.0
Commit 903644385b* (2017-06-19 13:05 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
WORD_SIZE: 64
Microsoft Windows [Version 10.0.15063]
Memory: 15.88791275024414 GB (6210.48828125 MB free)
Uptime: 17810.8402715 sec
Load Avg: 0.0 0.0 0.0
Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz:
speed user nice sys idle irq ticks
#1 2904 MHz 460625 0 522703 16827765 52187 ticks
#2 2904 MHz 504062 0 504156 16802671 121234 ticks
#3 2904 MHz 643250 0 423406 16744234 2890 ticks
#4 2904 MHz 900031 0 460312 16450546 3750 ticks

BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Prescott)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
Environment:
DOCKER_TOOLBOX_INSTALL_PATH = C:\Program Files\Docker Toolbox
HOMEDRIVE = C:
HOMEPATH = \Users\sdmca
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
VBOX_MSI_INSTALL_PATH = C:\Program Files\Oracle\VirtualBox\

JLD can't read files written by JLD2.

julia> z = load("multiruns2.jld","enron")
ERROR: unrecognized HDF5 datatype class 7

multiruns2.jld was the result of

f = JLD2.jldopen("multiruns2.jld","w")
write(f, "enron", z)
close(f)

Closures

Will/can JLD2 store closures?

expost API for testing type consistency

If a user writes values of a type

struct Foo
    a::Int64
end

and then later redefines the type as

struct Foo
    a::Int64
    b::Int64
end

and reads from a jld2 file, JLD2 (and also, of course, JLD) can catch the inconsistency between the two definitions. It would be great have the API for this exposed, eg as write_type_fingerprint(jldfile, "Foo", Foo) and similarly as a read method.

h5dump compatibility

I was taking a look at JuliaIO/JLD.jl#168 and noticed that it's fixed here (yay!). I went looking for clues with h5dump, and noticed that the demo in that issue, when saved as a .jld2, doesn't support h5dump.

Slow performance on Tuple{Type1, Type2}

Here's a fun one that's an issue both here and for JLD. Since this is under "deeper" development, I thought I'd report it here.

The issue is that tuples can lead to a big penalty due to code specialization. This was discovered in the course of JuliaGraphics/Colors.jl@690f56e, where initially I used tuples like (Vector{RGB},Vector{HSV}) to store the expected results of conversion from many pairs of color spaces.

Demo:

using JLD2

vals = [Val{i}() for i = 1:20]
fn = tempname()
file = jldopen(fn, "w")
write(file, "val0", Val{0}())
@time write(file, "vals", vals)

valsa = [Any[vals[i],vals[j]] for i = 1:length(vals), j= 1:length(vals)]
@time write(file, "valsa", valsa)

valst = [(vals[i],vals[j]) for i = 1:length(vals), j = 1:length(vals)]
@time write(file, "valst", valst)

close(file)

Output:

julia> include("jldtest.jl")
  3.534846 seconds (3.09 M allocations: 132.546 MB, 1.48% gc time)
  0.311439 seconds (297.17 k allocations: 12.700 MB, 2.75% gc time)
 64.548822 seconds (45.51 M allocations: 1.928 GB, 1.57% gc time)

and obviously the result is quadratic in length(vals). The second run is fast, demonstrating that it's a codegen issue:

julia> include("jldtest.jl")
  0.000606 seconds (745 allocations: 30.797 KB)
  0.000872 seconds (1.27 k allocations: 70.797 KB)
  0.011489 seconds (11.75 k allocations: 511.844 KB)

This seems to argue for some kind of "late binding of types" design wherever possible?

The serializer has the same issue, but the coefficient is smaller:

julia> serialize(io, Val{0}())

julia> @time serialize(io, vals)
  0.818252 seconds (775.42 k allocations: 31.418 MB, 3.82% gc time)

julia> @time serialize(io, valsa)
  0.124597 seconds (147.32 k allocations: 6.075 MB)

julia> @time serialize(io, valst)
  4.480248 seconds (2.99 M allocations: 118.578 MB, 1.69% gc time)

julia> @time serialize(io, valsa)
  0.001521 seconds (2.42 k allocations: 389.188 KB)

julia> @time serialize(io, valst)
  0.011649 seconds (2.41 k allocations: 301.281 KB)

customserialization

Following the example in customserialization.jl I wrote the following for KnetArrays:

type KnetJLD; a::Array; end
JLD2.writeas(::Type{KnetArray}) = KnetJLD
JLD2.wconvert(::Type{KnetJLD}, x::KnetArray) = KnetJLD(Array(x))
JLD2.rconvert(::Type{KnetArray}, x::KnetJLD) = KnetArray(x.a)

However I still get "cannot write a pointer to JLD file" error when I try to save a KnetArray. What am I doing wrong? (KnetArray has a cuda pointer in it).

Access to undefined reference on nightly

From the macOS nightly Travis log:

ERROR: LoadError: LoadError: UndefRefError: access to undefined reference
Stacktrace:
 [1] iseq(::MyStruct, ::MyStruct) at /Users/travis/.julia/v0.7/JLD2/test/rw.jl:288
 [2] macro expansion at /Users/travis/.julia/v0.7/JLD2/test/rw.jl:318 [inlined]
 [3] macro expansion at ./util.jl:238 [inlined]
 [4] macro expansion at /Users/travis/.julia/v0.7/JLD2/test/rw.jl:475 [inlined]
 [5] anonymous at ./<missing>:?
 [6] include_relative(::Module, ::String) at ./loading.jl:464
 [7] include at ./sysimg.jl:14 [inlined]
 [8] include(::String) at ./client.jl:381
 [9] include_relative(::Module, ::String) at ./loading.jl:464
 [10] include(::Module, ::String) at ./sysimg.jl:14
 [11] process_options(::Base.JLOptions) at ./client.jl:315
 [12] _start() at ./client.jl:383
while loading /Users/travis/.julia/v0.7/JLD2/test/rw.jl, in expression starting on line 359
while loading /Users/travis/.julia/v0.7/JLD2/test/runtests.jl, in expression starting on line 6

Full macOS log. The same happens on AppVeyor.

Something slightly different happens on Linux and for whatever reason Travis still reports success:

Internal error: encountered unexpected error in runtime:
ErrorException("type does not have a definite number of fields")
rec_backtrace at /home/centos/buildbot/slave/package_tarball64/build/src/stackwalk.c:86
record_backtrace at /home/centos/buildbot/slave/package_tarball64/build/src/task.c:246
jl_throw at /home/centos/buildbot/slave/package_tarball64/build/src/task.c:566
fieldcount at ./reflection.jl:457 [inlined]
fieldnames at ./reflection.jl:143
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:366 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:385 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1929
is_allocation at ./inference.jl:5645
...

Full Linux log

Broken by codegen rewrite

โžœ  JLD2 git:(master) โœ— julia test/runtests.jl 
WARNING: Base.Nothing is deprecated, use Void instead.
WARNING: Base.Nothing is deprecated, use Void instead.
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
WARNING: Base.Nothing is deprecated, use Void instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.Nothing is deprecated, use Void instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.String is deprecated, use AbstractString instead.
WARNING: Base.Nothing is deprecated, use Void instead.
WARNING: Base.Nothing is deprecated, use Void instead.
WARNING: Base.Nothing is deprecated, use Void instead.
WARNING: Base.None is deprecated, use Union{} instead.
WARNING: Base.None is deprecated, use Union{} instead.
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
in call at /Users/simon/.julia/v0.5/DataStructures/src/hashdict.jl:30
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
in call at /Users/simon/.julia/v0.5/DataStructures/src/hashdict.jl:30
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
in call at /Users/simon/.julia/v0.5/DataStructures/src/hashdict.jl:30
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
in call at /Users/simon/.julia/v0.5/DataStructures/src/hashdict.jl:30
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
in rehash at /Users/simon/.julia/v0.5/DataStructures/src/hashdict.jl:171
/var/folders/jv/h44t3bps20904rj8qtzzbjdw0000gn/T/test.jld
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
in rehash at /Users/simon/.julia/v0.5/DataStructures/src/hashdict.jl:171
 13.259108 seconds (18.70 M allocations: 802.910 MB, 1.32% gc time)

signal (11): Segmentation fault: 11
_ZNK4llvm5Value10getValueIDEv at /usr/local/julia/usr/include/llvm/IR/Value.h:231
_ZL17emit_bits_compareRK10jl_cgval_tS1_P12jl_codectx_t at /usr/local/julia/src/codegen.cpp:2050
_ZL10emit_errorRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEP12jl_codectx_t at /usr/local/julia/src/./cgutils.cpp:892
_ZL9emit_callPP11_jl_value_tmP12jl_codectx_tS0_ at /usr/local/julia/src/codegen.cpp:2808
_ZL13emit_functionP17_jl_lambda_info_t at /usr/local/julia/src/codegen.cpp:4911
_Z19jl_eh_restore_stateP13_jl_handler_t at /usr/local/julia/src/./julia.h:1359
jl_compile at /usr/local/julia/src/codegen.cpp:940
jl_trampoline_compile_function at /usr/local/julia/src/builtins.c:1015
jl_apply at /usr/local/julia/src/./julia.h:1274
jl_apply at /usr/local/julia/src/gf.c:1691
jl_apply at /usr/local/julia/src/interpreter.c:55
eval at /usr/local/julia/src/interpreter.c:213
do_call at /usr/local/julia/src/interpreter.c:63
eval at /usr/local/julia/src/interpreter.c:213
eval_body at /usr/local/julia/src/interpreter.c:548
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
eval_body at /usr/local/julia/src/interpreter.c:599
jl_interpret_toplevel_thunk_with at /usr/local/julia/src/interpreter.c:613
jl_toplevel_eval_flex at /usr/local/julia/src/toplevel.c:488
jl_parse_eval_all at /usr/local/julia/src/toplevel.c:577
jl_load at /usr/local/julia/src/toplevel.c:620
include at ./boot.jl:260
include_from_node1 at ./loading.jl:304
jl_apply at /usr/local/julia/src/interpreter.c:55
eval at /usr/local/julia/src/interpreter.c:213
jl_toplevel_eval_flex at /usr/local/julia/src/toplevel.c:527
jl_parse_eval_all at /usr/local/julia/src/toplevel.c:577
jl_load at /usr/local/julia/src/toplevel.c:620
include at ./boot.jl:260
include_from_node1 at ./loading.jl:304
process_options at ./client.jl:316
_start at ./client.jl:413
jlcall__start_19087 at /usr/local/julia/usr/lib/julia/sys.dylib (unknown line)
true_main at /usr/local/julia/usr/bin/julia (unknown line)
main at /usr/local/julia/usr/bin/julia (unknown line)
fish: Job 1, 'julia test/runtests.jl ' terminated by signal SIGSEGV (Address boundary error)

Works on release-0.4, so I'm assuming it's the codegen rewrite. cc @vtjnash

Problem reading dictionary

My MWE (Edit: import Colors.jl also):

import JLD2, Colors

function generator(size, ฮฒ, runs, name)

    parameters = Dict(  "size" => size,
                        "beta" => ฮฒ,
                        "runs" => runs)

    JLD2.jldopen(name, "w") do file
        file["parameters"] = parameters
    end
end

size, ฮฒ, runs = 10, 1.0, 10
generator(size, ฮฒ, runs, "issue.jld2")

JLD2.jldopen("issue.jld2", "r+") do file
    @show file["parameters"]
end

which throws

LoadError: field "second" of type Pair{String,Any} must be defined in the current workspace, but was undefined in the file

If I set instead size, ฮฒ, runs = 10, 10, 10, I get wrong values:

file["parameters"] = Dict("runs"=>0,"size"=>0,"beta"=>0)

Am I missing something?

Version info:

julia> Pkg.status("JLD2")
 - JLD2                          0.0.2+             master
julia> Pkg.status("Colors")
 - Colors                        0.8.0

julia> versioninfo()
Julia Version 0.6.1-pre.0
Commit dcf39a1dda (2017-06-19 13:06 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

Determine ideal way to enlarge a file

It seems like pwrite is faster on Linux and truncate is faster on OS X. But perhaps on Linux and other platforms that support it we should use posix_fallocate. Also just because truncate is faster doesn't mean it's the right approach; it may cause undesirable fragmentation vs. other approaches.

Testing on Windows

Hi, when you have a chance to continue on this (JuliaLang/julia#7909 said you would not be able to work on this until your PhD was done) feel free to ask that I test on Windows.

File saved with JLD2 can't be read, from identical OS and JLD2 version

Hello, I am facing a serious problem, namely that a file saved with JLD2 version 0.0.5 and FileIO cannot be read from the same OS with the same version of JLD2.

It is really weird for me because I have a bunch of files (computed with different parameters of a model) and most of them work perfectly.

Notice that for all of my files being computed, STDERR was empty, and STDOUT was exactly as expected (reporting some timings of computations and whatever).

I know paste my error messages:

image

which does not work. However, another file, produced by the identical code with one parameter different (positive instead of negative energy):

image

I have no reason to believe that there is something wrong with the data of the first case, as I have done the computation for one sub-case and it work.

I am more than willing to share the 2 files presented here if they can help (I really need some help since I cannot load some long-running cluster results).

saving >2GB file on Windows 7 gives ERROR: SystemError: truncate: Invalid Argument

On Windows 7, Julia v0.6.0, FileIO v0.5.2, JLD2 0.0.4.

using FileIO, JLD2
N = 10^4
M = 10^4
a = rand(Float32, N, M)
b = rand(Float32, N, M)
c = rand(Float32, N, M)
d = rand(Float32, N, M)
e = rand(Float32, N, M)
f = rand(Float32, N, M)
save("test_foo.jld2", Dict("a" => a, "b" => b, "c" => c, "d" => d, "e" => e, "f" => f))

gives

Error encountered while saving "test_foo.jld2".
Fatal error:
ERROR: SystemError: truncate: Invalid argument
Stacktrace:
 [1] #systemerror#44 at .\error.jl:64 [inlined]
 [2] systemerror(::String, ::Bool) at .\error.jl:64
 [3] truncate(::IOStream, ::Int64) at .\iostream.jl:43
 [4] truncate_and_close(::JLD2.MmapIO, ::Int64) at C:\Users\jj\.julia\v0.6\
JLD2\src\mmapio.jl:164
 [5] close(::JLD2.JLDFile{JLD2.MmapIO}) at C:\Users\jj\.julia\v0.6\JLD2\src
\JLD2.jl:364
 [6] #jldopen#29(::Array{Any,1}, ::Function, ::JLD2.##35#36{Dict{String,Array{Fl
oat32,2}}}, ::String, ::Vararg{String,N} where N) at C:\Users\jj\.julia\v0.
6\JLD2\src\loadsave.jl:6
 [7] #save#34(::Array{Any,1}, ::Function, ::FileIO.File{FileIO.DataFormat{:JLD2}
}, ::Dict{String,Array{Float32,2}}) at C:\Users\jj\.julia\v0.6\JLD2\src\loa
dsave.jl:85
 [8] save(::FileIO.File{FileIO.DataFormat{:JLD2}}, ::Dict{String,Array{Float32,2
}}) at C:\Users\jj\.julia\v0.6\JLD2\src\loadsave.jl:85
 [9] eval(::Module, ::Any) at .\boot.jl:235
 [10] #save#21(::Array{Any,1}, ::Function, ::FileIO.File{FileIO.DataFormat{:JLD2
}}, ::Dict{String,Array{Float32,2}}, ::Vararg{Dict{String,Array{Float32,2}},N} w
here N) at C:\Users\jj\.julia\v0.6\FileIO\src\loadsave.jl:115
 [11] save(::FileIO.File{FileIO.DataFormat{:JLD2}}, ::Dict{String,Array{Float32,
2}}) at C:\Users\jj\.julia\v0.6\FileIO\src\loadsave.jl:106
 [12] #save#14(::Array{Any,1}, ::Function, ::String, ::Dict{String,Array{Float32
,2}}, ::Vararg{Dict{String,Array{Float32,2}},N} where N) at C:\Users\jj\.ju
lia\v0.6\FileIO\src\loadsave.jl:61
 [13] save(::String, ::Dict{String,Array{Float32,2}}) at C:\Users\jj\.julia
\v0.6\FileIO\src\loadsave.jl:61

If N and M are chosen smaller (<2GB), saving works.

Cannot save Dict with key or value type being Union

On current JLD2 master with Julia 0.6.2, I receive an error when trying to save a Dict where at least one of two conditions hold:

  1. The key type is a Union containing Dict.
  2. The value type is a Union containing a container (errors on both Dict and Vector).

It also does not require that I fill in any of the values within these Dicts, it still occurs whether they're empty or not.

MWE:

using JLD2
d = Dict{Int,Union{Int,Dict}}()
@save "test.jld2" d

ERROR: MethodError: Cannot `convert` an object of type Type{Dict} to an object of type DataType
This may have arisen from a call to the constructor DataType(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] copy!(::IndexLinear, ::Array{DataType,1}, ::IndexLinear, ::Array{Any,1}) at ./abstractarray.jl:656
 [2] h5convert!(::JLD2.IndirectPointer, ::Type{JLD2.Vlen{JLD2.OnDiskRepresentation{(0, 16),Tuple{String,Array{Any,1}},Tuple{JLD2.Vlen{String},JLD2.Vlen{JLD2.RelOffset}}}()}}, ::JLD2.JLDFile{JLD2.MmapIO}, ::Union, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/data.jl:961
 [3] write_data(::JLD2.MmapIO, ::JLD2.JLDFile{JLD2.MmapIO}, ::Type{T} where T, ::Type{JLD2.Vlen{JLD2.OnDiskRepresentation{(0, 16),Tuple{String,Array{Any,1}},Tuple{JLD2.Vlen{String},JLD2.Vlen{JLD2.RelOffset}}}()}}, ::JLD2.HasReferences, ::JLD2.JLDWriteSession{Dict{UInt64,
JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/dataio.jl:111
 [4] write_dataset(::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.WriteDataspace{0,Tuple{}}, ::JLD2.CommittedDatatype, ::Type{JLD2.Vlen{JLD2.OnDiskRepresentation{(0, 16),Tuple{String,Array{Any,1}},Tuple{JLD2.Vlen{String},JLD2.Vlen{JLD2.RelOffset}}}()}}, ::Type{T} where T, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/datasets.jl:427
 [5] write_ref(::JLD2.JLDFile{JLD2.MmapIO}, ::Type{T} where T, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/datasets.jl:536
 [6] (::JLD2.##23#24{JLD2.JLDFile{JLD2.MmapIO},JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}})(::Type{T} where T) at /home/jpsamaroo/.julia/v0.6/JLD2/src/data.jl:880
 [7] next(::Base.Generator{SimpleVector,JLD2.##23#24{JLD2.JLDFile{JLD2.MmapIO},JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}}}, ::Int64) at ./generator.jl:45
 [8] copy!(::Array{JLD2.RelOffset,1}, ::Base.Generator{SimpleVector,JLD2.##23#24{JLD2.JLDFile{JLD2.MmapIO},JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}}}) at ./abstractarray.jl:573
 [9] _collect(::Type{JLD2.RelOffset}, ::Base.Generator{SimpleVector,JLD2.##23#24{JLD2.JLDFile{JLD2.MmapIO},JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}}}, ::Base.HasLength) at ./array.jl:395
 [10] collect(::Type{JLD2.RelOffset}, ::Base.Generator{SimpleVector,JLD2.##23#24{JLD2.JLDFile{JLD2.MmapIO},JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}}}) at ./array.jl:393
 [11] h5convert!(::JLD2.IndirectPointer, ::JLD2.OnDiskRepresentation{(0, 16),Tuple{String,Array{Any,1}},Tuple{JLD2.Vlen{String},JLD2.Vlen{JLD2.RelOffset}}}, ::JLD2.JLDFile{JLD2.MmapIO}, ::DataType, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/data.jl:865
 [12] write_data(::JLD2.MmapIO, ::JLD2.JLDFile{JLD2.MmapIO}, ::DataType, ::JLD2.OnDiskRepresentation{(0, 16),Tuple{String,Array{Any,1}},Tuple{JLD2.Vlen{String},JLD2.Vlen{JLD2.RelOffset}}}, ::JLD2.HasReferences, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/dataio.jl:111
 [13] write_attribute(::JLD2.MmapIO, ::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.WrittenAttribute{JLD2.WriteDataspace{0,Tuple{}},JLD2.CommittedDatatype,DataType}, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/attributes.jl:48
 [14] commit(::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.BasicDatatype, ::Tuple{JLD2.WrittenAttribute{JLD2.WriteDataspace{0,Tuple{}},JLD2.CommittedDatatype,DataType},JLD2.WrittenAttribute{JLD2.WriteDataspace{0,Tuple{}},JLD2.CommittedDatatype,DataType}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/datatypes.jl:265
 [15] commit(::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.BasicDatatype, ::DataType, ::DataType) at /home/jpsamaroo/.julia/v0.6/JLD2/src/data.jl:242
 [16] h5fieldtype(::JLD2.JLDFile{JLD2.MmapIO}, ::Type{Array{Pair{Int64,Union{Dict, Int64}},1}}, ::DataType, ::Type{Val{true}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/data.jl:1011
 [17] write(::JLD2.Group{JLD2.JLDFile{JLD2.MmapIO}}, ::String, ::Dict{Int64,Union{Dict, Int64}}, ::JLD2.JLDWriteSession{Dict{UInt64,JLD2.RelOffset}}) at /home/jpsamaroo/.julia/v0.6/JLD2/src/groups.jl:119
 [18] #jldopen#31(::Array{Any,1}, ::Function, ::##19#20, ::String, ::Vararg{String,N} where N) at /home/jpsamaroo/.julia/v0.6/JLD2/src/loadsave.jl:4
 [19] jldopen(::Function, ::String, ::String) at /home/jpsamaroo/.julia/v0.6/JLD2/src/loadsave.jl:2
Pkg.status("JLD2")
 - JLD2                          0.0.5+             master

saving Array{Any,2}(80000,28)

I have an array a = Array{Any,2}(80000,28)
and do the following:

f = jldopen("testfile.jld2","w")
for i in 1:28
f["dataset/var$i"]=a[:,i]
end

This crashes my windows 10 and windows 7 pc running Julia 0.6.

The issue doesn't occur if a = Array{String,2}, so I assume using the Any type is to be avoided.

Align bitstype arrays in file

This would be nice if we ever want to support mmaparrays here, which is currently accepted as an option but ignored.

Option to read slices of stored arrays

Is it possible to read parts of arrays stored as JLD2 files (a specific slice), like in the HDF5.jl example?

using HDF5
h5read("/tmp/test2.h5", "mygroup2/A", (2:3:15, 3:5))

File saved with JLD2 can't be read

Back on June 1, I saved a file using JLD2. Packages have been updated since then, and now I can't read the file back in:

julia> f = JLD2.jldopen("multiruns.jld","r")
ERROR: JLD2.InvalidDataException()
Stacktrace:
 [1] read(::JLD2.MmapIO, ::Type{JLD2.Superblock}) at /Users/seth/.julia/v0.6/JLD2/src/superblock.jl:25
 [2] jldopen(::String, ::Bool, ::Bool, ::Bool) at /Users/bromberger1/.julia/v0.6/JLD2/src/JLD2.jl:174
 [3] jldopen(::String, ::String) at /Users/bromberger1/.julia/v0.6/JLD2/src/JLD2.jl:220

Not sure what to do here.

phasebang:ca-condmat2$ ls -l multiruns.jld
-rw-r--r--  1 bromberger1  56797  1048613693 Jun  2 11:24 multiruns.jld
phasebang:ca-condmat2$ file multiruns.jld
multiruns.jld: data
phasebang:ca-condmat2$ head multiruns.jld
Julia data file (HDF5), version 0.2.0OHDR๏ฟฝ>@6 name9parameters97

(JLD.jl can't read it either.)

saving large dictionary hangs at 262144 bytes

rmap is a Dict{String, Int} with ~300 million entries. The strings are each 64 hex characters, and the ints are 1..length(rmap).

@save "myfile.jld2 rmap writes 262144 bytes to the file and then hangs indefinitely (I've waited about 10 mins so far and this is all that's shown up):

$ ls -l myfile.jld2 
-rw-r--r--. 1 me mygroup 262144 Feb 15 14:34 myfile.jld2
$ file myfile.jld2 
myfile.jld2: data

Julia v0.6.2, JLD2 v0.0.5, 64-bit Linux.

Adapt JLD2 for isbits union fields

As implemented in JuliaLang/julia#22441. At the moment, this is impossible, because Julia does not correctly construct these objects. But once it does, there is the question of how these should be written in the file. Obvious options are:

  • Write union-typed fields the same way we do now, by saving the field content in its own dataset. This might be easier for non-JLD2 implementations to consume, since it's a closer match with the HDF5 data model, but writing a dataset has substantially overhead in terms of both space and time vs. how Julia handles this in memory. It would be nice if the cost of saving/loading data with JLD2 was closely related to the cost of working with said data in Julia.
  • Create datatypes for isbits unions. HDF5 doesn't actually support unions, but we could save a datatype structured like:
DATATYPE "00000002" H5T_COMPOUND {
         H5T_STD_I64LE "Int64";
         H5T_IEEE_F64LE "Float64";
         H5T_STD_U8LE "uniontype";
      }

where only one of the fields will be initialized, and the ty field will say which one. In principle this wastes some space in the file since only the Int64 or Float64 field will contain data, but the storage overhead is smaller than the storage overhead from creating a new dataset, and in the likely common case of Union{T,Null}, we would just be storing an extra byte to signal whether the value was null or not.

This would be a breaking change in that older versions of JLD2 wouldn't be able to read files created with newer versions, although newer versions of JLD2 should still be able to handle files created with older versions.

Tuple-of-type-of-closure cannot be reloaded

On 0.6,

julia> using FileIO, JLD2

julia> myfun() = x -> x
myfun (generic function with 1 method)

julia> save("test2.jld2", "groups", (typeof(myfun()),))

#### new session

julia> using FileIO, JLD2

julia> groups2 = load("test2.jld2", "groups")
Error encountered while loading "/Users/cedric/Programa/RL/notebooks/test2.jld2".
Fatal error:
ERROR: TypeError: read_data: in typeassert, expected DataType, got JLD2.UnknownType{String}
Stacktrace:
 [1] jlconvert at /Users/cedric/.julia/v0.6/JLD2/src/data.jl:1229 [inlined]
 [2] read_scalar at /Users/cedric/.julia/v0.6/JLD2/src/dataio.jl:37 [inlined]
 [3] read_data(::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.ReadRepresentation{Tuple{DataType},JLD2.OnDiskRepresentation{(0,),Tuple{DataType},Tuple{JLD2.OnDiskRepresentation{(0, 16),Tuple{String,Array{Any,1}},Tuple{JLD2.Vlen{String},JLD2.Vlen{JLD2.RelOffset}}}()}}()}, ::Array{JLD2.ReadAttribute,1}) at /Users/cedric/.julia/v0.6/JLD2/src/datasets.jl:171
 [4] read_data(::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.ReadDataspace, ::UInt8, ::Int64, ::Int64, ::Int64, ::UInt16, ::JLD2.RelOffset, ::Array{JLD2.ReadAttribute,1}) at /Users/cedric/.julia/v0.6/JLD2/src/datasets.jl:149
 [5] load_dataset(::JLD2.JLDFile{JLD2.MmapIO}, ::JLD2.RelOffset) at /Users/cedric/.julia/v0.6/JLD2/src/datasets.jl:92
 [6] getindex(::JLD2.Group{JLD2.JLDFile{JLD2.MmapIO}}, ::String) at /Users/cedric/.julia/v0.6/JLD2/src/groups.jl:108

EDIT: I expected to see ReconstructedType, instead of an error.

Improve compression

Right now compression is implemented in the most naive possible way, and only zlib is implemented. It would be nice to have a faster option (e.g. Blosc or LZ4) and also not have to buffer everything in memory before writing to disk.

Bad saving of interactively-defined function in tuple

The function disappears from the tuple:

julia> using JLD2, FileIO

julia> f(x) = x+1
f (generic function with 1 method)

julia> save("test.jld2", "tuple", (f, :hello))

### New session

julia> using JLD2, FileIO

julia> load("test.jld2", "tuple")
(:hello,)

segmentation fault during Pkg.test, linux, Julia 0.6.2

@gruffalo[101]% uname -a
Linux gruffalo 2.6.32-696.18.7.el6.x86_64 #1 SMP Thu Jan 4 17:31:22 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
@gruffalo[102]% julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

ERROR: Invalid history file (.julia_history) format:
If you have a history file left over from an older version of Julia,
try renaming or deleting it.
Invalid character: '[' at line 354
Stacktrace:
 [1] hist_from_file(::Base.REPL.REPLHistoryProvider, ::IOStream, ::String) at ./REPL.jl:352
 [2] #setup_interface#23(::Bool, ::Array{Dict{Any,Any},1}, ::Function, ::Base.REPL.LineEditREPL) at ./REPL.jl:771
 [3] run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at ./REPL.jl:940
 [4] run_repl(::Base.REPL.LineEditREPL, ::Base.##510#511) at ./REPL.jl:180
 [5] _start() at ./client.jl:413

INFO: Disabling history file for this session.
julia> Pkg.update("JLD2")
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove

julia> Pkg.test("JLD2")
INFO: Testing JLD2
/tmp/test.jld
 30.891543 seconds (13.04 M allocations: 650.316 MiB, 1.61% gc time)

signal (11): Segmentation fault
while loading /u4/vavasis/.julia/v0.6/JLD2/test/rw.jl, in expression starting on line 355
unknown function (ip: 0x7f19b24e42c7)
unknown function (ip: 0x7f1ab24e4ec6)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
getindex at /u4/vavasis/.julia/v0.6/JLD2/src/groups.jl:108
unknown function (ip: 0x7f1ab24e3d26)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
read at /u4/vavasis/.julia/v0.6/JLD2/src/JLD2.jl:328
unknown function (ip: 0x7f1ab24e3696)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
macro expansion at /u4/vavasis/.julia/v0.6/JLD2/test/rw.jl:311 [inlined]
macro expansion at ./util.jl:237 [inlined]
macro expansion at /u4/vavasis/.julia/v0.6/JLD2/test/rw.jl:472 [inlined]
anonymous at ./<missing> (unknown line)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:589
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:873
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:616
include_from_node1 at ./loading.jl:576
unknown function (ip: 0x7f1a2cd50622)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
include at ./sysimg.jl:14
unknown function (ip: 0x7f1ab7c959eb)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:75
eval at /buildworker/worker/package_linux64/build/src/interpreter.c:242
jl_interpret_toplevel_expr at /buildworker/worker/package_linux64/build/src/interpreter.c:34
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:577
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:873
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:616
include_from_node1 at ./loading.jl:576
unknown function (ip: 0x7f1ab7dfd38b)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
include at ./sysimg.jl:14
unknown function (ip: 0x7f1ab7c959eb)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
process_options at ./client.jl:305
_start at ./client.jl:371
unknown function (ip: 0x7f1ab7e0bd28)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
jl_apply at /buildworker/worker/package_linux64/build/ui/../src/julia.h:1424 [inlined]
true_main at /buildworker/worker/package_linux64/build/ui/repl.c:127
main at /buildworker/worker/package_linux64/build/ui/repl.c:264
__libc_start_main at /lib64/libc.so.6 (unknown line)
unknown function (ip: 0x4016bc)
Allocations: 24405283 (Pool: 24398000; Big: 7283); GC: 53
================================[ ERROR: JLD2 ]=================================

failed process: Process(`/fsys1/.software/arch/julia-0.6.2/distribution/julia-d386e40c17/bin/julia -Cx86-64 -J/fsys1/.software/arch/julia-0.6.2/distribution/julia-d386e40c17/lib/julia/sys.so --compile=yes --depwarn=yes --check-bounds=yes --code-coverage=none --color=yes --compilecache=yes /u4/vavasis/.julia/v0.6/JLD2/test/runtests.jl`, ProcessSignaled(11)) [0]

================================================================================
ERROR: JLD2 had test errors

julia>

segfault when passing an IOStream to JLD2.load

After

a = sprand(100, 100, 0.5)
@save "testjld2" a

I tried to pass an IOStream to load:

f = open("testjld2", "r")
# IOStream(<file testjld2>)

JLD2.load(f)
Segmentation fault: 11

It'd be great if JLD2.load could take an IOStream. The docs imply that it should work.

Migration plan?

Since this package is now working on all platforms, I think it's about time to release it. I'm not sure exactly how to do that. I see a few options:

  • Start with a separate package from JLD.jl, and merge once it's seen wider use. (The only potentially complication here is if/how the package should be integrated with FileIO.)
  • Move code here to JLD.jl, but don't enable by default, since it hasn't received the same degree of testing. Once it sees wider use, enable it by default.
  • Move code here to JLD.jl and immediately enable by default. I'm a little hesitant to do this, since there may be cases I'm not handling properly yet.

JLD2 not installing under latest 0.7-DEV

I'm trying to port my code from 0.6.2 to 0.7-DEV (0-day old master) and so far I haven't been able to install either JLD or JLD2 (Ubuntu 17.10). The installation of JLD2 is failing because the code is apparently not able to find libz. Below is the error message.

[ Info: Precompiling module JLD2
โ”Œ Warning: Deprecated syntax `type` at /home/vavasis/.julia/v0.7/Libz/src/lowlevel.jl:62.
โ”‚ Use `mutable struct` instead.
โ”” @ nothing lowlevel.jl:62
โ”Œ Warning: `is_windows` is deprecated, use `Sys.iswindows` instead.
โ”‚   caller = top-level scope
โ”” @ Core :0
WARNING: importing deprecated binding Base.Void into Libz.
WARNING: Base.Void is deprecated, use Nothing instead.
  likely near /home/vavasis/.julia/v0.7/Libz/src/lowlevel.jl:62
WARNING: Base.Void is deprecated, use Nothing instead.
  likely near /home/vavasis/.julia/v0.7/Libz/src/lowlevel.jl:62
WARNING: Base.Void is deprecated, use Nothing instead.
  likely near /home/vavasis/.julia/v0.7/Libz/src/lowlevel.jl:62
WARNING: Base.Void is deprecated, use Nothing instead.
  likely near /home/vavasis/.julia/v0.7/Libz/src/lowlevel.jl:62
ERROR: LoadError: LoadError: error compiling version: could not load library "libz"
libz.so: cannot open shared object file: No such file or directory
Stacktrace:
 [1] top-level scope
 [2] include at ./boot.jl:295 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1060
 [4] include at ./sysimg.jl:27 [inlined]
 [5] include(::String) at /home/vavasis/.julia/v0.7/Libz/src/Libz.jl:3
 [6] top-level scope
 [7] include at ./boot.jl:295 [inlined]
 [8] include_relative(::Module, ::String) at ./loading.jl:1060
 [9] include(::Module, ::String) at ./sysimg.jl:27
 [10] top-level scope
 [11] eval at ./boot.jl:298 [inlined]
 [12] top-level scope at ./<missing>:3
in expression starting at /home/vavasis/.julia/v0.7/Libz/src/lowlevel.jl:110
in expression starting at /home/vavasis/.julia/v0.7/Libz/src/Libz.jl:11
ERROR: LoadError: Failed to precompile Libz to /home/vavasis/.julia/lib/v0.7/Libz.ji.
Stacktrace:
 [1] error at ./error.jl:33 [inlined]
 [2] compilecache(::Base.PkgId) at ./loading.jl:1198
 [3] _require(::Base.PkgId) at ./loading.jl:967
 [4] require(::Module, ::Symbol) at ./loading.jl:867
 [5] include at ./boot.jl:295 [inlined]
 [6] include_relative(::Module, ::String) at ./loading.jl:1060
 [7] include(::Module, ::String) at ./sysimg.jl:27
 [8] top-level scope
 [9] eval at ./boot.jl:298 [inlined]
 [10] top-level scope at ./<missing>:3
in expression starting at /home/vavasis/.julia/v0.7/JLD2/src/JLD2.jl:4
ERROR: LoadError: Failed to precompile JLD2 to /home/vavasis/.julia/lib/v0.7/JLD2.ji.
Stacktrace:
 [1] error at ./error.jl:33 [inlined]
 [2] compilecache(::Base.PkgId) at ./loading.jl:1198
 [3] _require(::Base.PkgId) at ./loading.jl:996
 [4] require(::Module, ::Symbol) at ./loading.jl:867
 [5] include at ./boot.jl:295 [inlined]
 [6] include_relative(::Module, ::String) at ./loading.jl:1060
 [7] include(::Module, ::String) at ./sysimg.jl:27
 [8] include(::String) at ./sysimg.jl:66
 [9] top-level scope
in expression starting at /home/vavasis/ownCloud/Documents/Katerina/cohesive/conic_jl/conic29.jl:8

julia> 

Implement compression

As of HDF5 File Format 3.0, this should be possible without implementing b-trees ๐ŸŽ‰

incremental compilation broken when saving to and loading from a JLD2 file in a module

__precompile__()
module Foo
using JLD2, FileIO
file = joinpath(@__DIR__, "foo.jld2")
save(file, "x", zeros(10))
load(file, "x")
end

results in

julia> using Foo
INFO: Recompiling stale cache file C:\Users\Daniel\.julia\lib\v0.6\Foo.ji for module Foo.
WARNING: eval from module Main to Foo:
Expr(:call, typeof(JLD2.save)(), Expr(:parameters, Expr(:..., Array{Any, 1}[])::Any)::Any, FileIO.Fi
le{FileIO.DataFormat{:JLD2}}(filename="C:\Users\Daniel\Cloud\TU Wien\Julia\modules\Foo\src\foo.jld2"
), Expr(:..., ("x", Array{Float64, 1}[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))::Any)::Any
  ** incremental compilation may be broken for this module **

WARNING: eval from module Main to Foo:
Expr(:call, typeof(JLD2.load)(), Expr(:parameters, Expr(:..., Array{Any, 1}[])::Any)::Any, FileIO.Fi
le{FileIO.DataFormat{:JLD2}}(filename="C:\Users\Daniel\Cloud\TU Wien\Julia\modules\Foo\src\foo.jld2"
), Expr(:..., ("x",))::Any)::Any
  ** incremental compilation may be broken for this module **

Something similar has already been reported for JLD in JuliaIO/JLD.jl#187

`load` and `save` should round-trip with groups

First off, thanks for the package, really helpful ๐Ÿ‘

I have a simple question, consider:

using FileIO

p1 = 1
p2 = 2.

data = [[1,2,3],[4.,5.,6.]]

save("foo.jld2", "params/p1", p1, "params/p2", p2, "data", data)

This will save the parameters in a group as expected. When I load it with jldopen("foo.jld2","r") and leave the file open, I have access to the parameters:

using JLD2

file = jldopen("foo.jld2","r")
p1 = file["params"]["p1"] # works fine

However, if I load the file with the FileIO interface, I get closed groups:

using FileIO

dict = load("foo.jld2")
dict["params"] # returns a closed group, no access to p1 nor p2

Is this expected behavior? Are we assuming that groups only work with the JLD2 interface?

segmentation fault trying to write a large array

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
unknown function (ip: 0x2aaa9db8a9d8)
write_dataset at /g/g17/seth/.julia/v0.6/JLD2/src/datasets.jl:398
write at /g/g17/seth/.julia/v0.6/JLD2/src/groups.jl:119
unknown function (ip: 0x2aae9db940f2)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
#33 at /g/g17/seth/.julia/v0.6/JLD2/src/loadsave.jl:50 [inlined]
#jldopen#31 at /g/g17/seth/.julia/v0.6/JLD2/src/loadsave.jl:4
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1424 [inlined]
jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:51
macro expansion at /g/g17/seth/.julia/v0.6/JLD2/src/loadsave.jl:48 [inlined]
savesg at /g/g17/seth/.julia/v0.6/StaticGraphs/src/persistence.jl:22
savegraph at /g/g17/seth/.julia/v0.6/StaticGraphs/src/persistence.jl:37
unknown function (ip: 0x2aae9db89b06)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:75
eval at /buildworker/worker/package_linux64/build/src/interpreter.c:242
jl_interpret_toplevel_expr at /buildworker/worker/package_linux64/build/src/interpreter.c:34
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:577
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x2aaaaeb92d2f)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x2aaaaec1418f)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x2aaadd68f3bf)
jl_call_fptr_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /buildworker/worker/package_linux64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:1926
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1424 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:267
unknown function (ip: 0xffffffffffffffff)
Allocations: 4246915010 (Pool: 4246897213; Big: 17797); GC: 2164
Segmentation fault (core dumped)

This was trying to write a {296537762, 740803610} directed simple static {UInt32, UInt32} graph which uses JLD2 here: https://github.com/JuliaGraphs/StaticGraphs.jl/blob/52dc3aca8258ae23708f4a823149ff4c9e85b626/src/persistence.jl#L17-L24 .

Segmentation fault when using @save

Hi, I using julia v 0.6.0 and getting the following error when running the basic save code:

using JLD2, FileIO
hello = "world"
foo = :bar
@save "example.jld2" hello foo

yields:

signal (11): Segmentation fault
while loading no file, in expression starting on line 48
_write at /home/brett/.julia/v0.6/JLD2/src/mmapio.jl:180 [inlined]
write at /home/brett/.julia/v0.6/JLD2/src/misc.jl:27 [inlined]
write_object_header_and_dataspace_message at /home/brett/.julia/v0.6/JLD2/src/datasets.jl:435
write_dataset at /home/brett/.julia/v0.6/JLD2/src/datasets.jl:423
write at /home/brett/.julia/v0.6/JLD2/src/groups.jl:119
unknown function (ip: 0x7fabd740b332)
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1933
#1 at /home/brett/.julia/v0.6/JLD2/src/loadsave.jl:50 [inlined]
#jldopen#29 at /home/brett/.julia/v0.6/JLD2/src/loadsave.jl:4
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1933
jldopen at /home/brett/.julia/v0.6/JLD2/src/loadsave.jl:2
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1933
do_call at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:75
eval at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:242
eval_body at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:543
jl_interpret_toplevel_thunk at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:692
jl_toplevel_eval_flex at /home/centos/buildbot/slave/package_tarball64/build/src/toplevel.c:592
jl_toplevel_eval_in at /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7fabebb6139f)
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1933
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x7fabebbcf1cf)
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1933
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x7fabd73f22af)
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1933
jl_apply at /home/centos/buildbot/slave/package_tarball64/build/src/julia.h:1424 [inlined]
start_task at /home/centos/buildbot/slave/package_tarball64/build/src/task.c:267
unknown function (ip: 0xffffffffffffffff)
Allocations: 3563789 (Pool: 3562454; Big: 1335); GC: 5
Segmentation fault (core dumped)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.