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

Field XXX has non-zero size in file, this should not happen #594

Closed
dpinol opened this issue Sep 9, 2024 · 5 comments
Closed

Field XXX has non-zero size in file, this should not happen #594

dpinol opened this issue Sep 9, 2024 · 5 comments

Comments

@dpinol
Copy link
Contributor

dpinol commented Sep 9, 2024

On version 0.5.1, when using typemap for upgrades, we get the following message for some kinds of types (for Symbols & enums, but not for Ints and Strings)
Field XXX has non-zero size in file, this should not happen

You can reproduce with this:

using JLD2

@enum MyEnum begin
    A = 1
end

Base.@kwdef struct KK
    enum::MyEnum = A
    int::Int = 0
    field::Symbol = :KK2
    str::String = "jkjk"
end

function JLD2.rconvert(::Type{KK}, deserialized::NamedTuple)
    return KK(; deserialized...)
end

save("kk.jld2", Dict("kk" => KK()))
load("kk.jld2"; typemap=Dict("KK" => JLD2.Upgrade(KK)))
┌ Warning: Field enum has non-zero size in file, this should not happen
└ @ JLD2 ~/.julia/packages/JLD2/JHhTf/src/data/reconstructing_datatypes.jl:595
┌ Warning: Field field has non-zero size in file, this should not happen
└ @ JLD2 ~/.julia/packages/JLD2/JHhTf/src/data/reconstructing_datatypes.jl:595
@JonasIsensee
Copy link
Collaborator

JonasIsensee commented Sep 9, 2024

Hm, I actually can't reproduce..

julia> using JLD2
Precompiling JLD2
  1 dependency successfully precompiled in 26 seconds. 7 already precompiled.

julia> @enum MyEnum begin
           A = 1
       end

julia> Base.@kwdef struct KK
           enum::MyEnum = A
           int::Int = 0
           field::Symbol = :KK2
           str::String = "jkjk"
       end
KK

julia> function JLD2.rconvert(::Type{KK}, deserialized::NamedTuple)
           return KK(; deserialized...)
       end

julia> save("kk.jld2", Dict("kk" => KK()))

julia> load("kk.jld2"; typemap=Dict("KK" => JLD2.Upgrade(KK)))
Dict{String, Any} with 1 entry:
  "kk" => KK(A, 0, :KK2, "jkjk")

I am not sure what is going on at your side.
You clearly managed to trigger the problem.
Will be happy to help with some more info.

What Julia version are you on?

@dpinol
Copy link
Contributor Author

dpinol commented Sep 9, 2024

Hi,
thanks for looking into this.
After some digging I found out it only happens when executing in a test with Jive.jl (or through Juliacall python library).
Looking at jive.jl code I found out that you can reproduce it with:

  • Write my code above in a file named kk.jl
  • Execute this from REPL Base.include(Module(), "kk.jl"). This is done to ensure that each test file is executed on a different Module to avoid that 'using's in one test file affect the other test files.

@dpinol
Copy link
Contributor Author

dpinol commented Sep 9, 2024

Btw, I also get these different messages in 0.5.1 when doing Base.include

┌ Warning: type Main.anonymous.KK does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/JHhTf/src/data/reconstructing_datatypes.jl:573
┌ Warning: type Main.anonymous.MyEnum does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/JHhTf/src/data/reconstructing_datatypes.jl:457

@JonasIsensee
Copy link
Collaborator

Ok, I found the problem.
Well, the problem is really just an overly eager warning message that I will need to remove.

This bit is expected and also exists on older versions:
You're storing types defined in an anonymous module. Therefore they are stored with name Main.anonymous.KK and cannot be recovered since Main.anonymous is not actually a valid name.

Btw, I also get these different messages in 0.5.1 when doing Base.include

┌ Warning: type Main.anonymous.KK does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/JHhTf/src/data/reconstructing_datatypes.jl:573
┌ Warning: type Main.anonymous.MyEnum does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/JHhTf/src/data/reconstructing_datatypes.jl:457

@dpinol
Copy link
Contributor Author

dpinol commented Sep 9, 2024

Cool, thanks!
My tests all pass so I agree that the problem doesn't affect the library behaviour.

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

No branches or pull requests

2 participants