Closed lijas closed 11 months ago
From your stacktrace I gather that somewhere in your FEM (?) structures there's a
Dict{Int, Nothing}
which I find questionable but this should of course work.
The error doesn't actually seem to occur within JLD2 code but rather in the Base.collect
call.
However, this works just fine for me.
d = Dict{Int, Nothing}(1=>nothing, 2=>nothing)
collect(d)
In the REPL, I was able to "dissect" my data struct, and it seems like it is a Set{Int}
that is causing the problem :thinking:
So it seems like it is an issue with JLD2?
julia> trimmed_voxels
Set{Int64} with 7915 elements:
4986
14215
7144
6073
4576
12778
9773
1956
15889
14288
8690
5975
2841
2876
12059
687
1090
9802
15833
12255
11280
11251
12715
422
4888
15859
7451
4030
551
11373
15931
14832
⋮
julia> @save "matrix_data.jld2" trimmed_voxels
ERROR: ArgumentError: destination has fewer elements than required
Stacktrace:
[1] copyto!(dest::Vector{Pair{Int64, Nothing}}, src::Dict{Int64, Nothing})
@ Base ./abstractarray.jl:947
[2] _collect
....
Edit: I think You are correct, if I do collect(trimmed_voxels.dict)
I get the same error.
I was pushing to a Set{Int} in a threaded loop, but sets are not thread-safe, so the error was somehow related to that .
I am randomly running in to a problem when I want save one of my structs. It fails about 50% of the time with this error message:
I tried making a MWE, but was not able to reproduce it. Is there any other information I can provide?. Or can the stacktrace provide enough information.