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

Serialization fails between different machines #75

Closed
aplavin opened this issue Feb 28, 2024 · 1 comment
Closed

Serialization fails between different machines #75

aplavin opened this issue Feb 28, 2024 · 1 comment

Comments

@aplavin
Copy link
Contributor

aplavin commented Feb 28, 2024

I serialized an object (with InlineStrings inside) on one machine, and wanted to read it from another computer. Sometimes it works, sometimes doesn't. The minimal example I found is this:

obj = [(a = InlineString15("a"), b = InlineString("b"),)]
# computer 1:
serialize("file", obj)
# computer 2:
deserialize("file", obj)
# throws
ERROR: EOFError: read end of file
Stacktrace:
  [1] unsafe_read
    @ ./iobuffer.jl:175 [inlined]
  [2] unsafe_read(s::IOBuffer, p::Ptr{@NamedTuple{a::InlineStrings.String15, b::InlineStrings.String1}}, n::Int64)
    @ Base ./io.jl:774
  [3] read!(s::IOBuffer, a::Vector{@NamedTuple{a::InlineStrings.String15, b::InlineStrings.String1}})
    @ Base ./io.jl:792
  [4] deserialize_array(s::Serializer{IOBuffer})
    @ Serialization ~/.julia/juliaup/julia-1.10.1+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Serialization/src/Serialization.jl:1241
  [5] handle_deserialize(s::Serializer{IOBuffer}, b::Int32)
    @ Serialization ~/.julia/juliaup/julia-1.10.1+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Serialization/src/Serialization.jl:865
  [6] deserialize(s::Serializer{IOBuffer})
    @ Serialization ~/.julia/juliaup/julia-1.10.1+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Serialization/src/Serialization.jl:814
  [7] handle_deserialize(s::Serializer{IOBuffer}, b::Int32)
    @ Serialization ~/.julia/juliaup/julia-1.10.1+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Serialization/src/Serialization.jl:920
  [8] deserialize
    @ ~/.julia/juliaup/julia-1.10.1+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Serialization/src/Serialization.jl:814 [inlined]
  [9] deserialize
    @ ~/.julia/juliaup/julia-1.10.1+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Serialization/src/Serialization.jl:801 [inlined]

Same package versions, same Julia version. Computer 1 is linux x64, computer 2 is macbook m2.

I have a bunch of files like this, so had to re-read them on computer 1, get rid of inlinestrings (they just happened to be there, not on purpose), and write back.
If others encounter this issue, that's an easy way to convert all inlinestrings to strings:

using AccessorsExtra, InlineStrings
obj = modify(String, obj, RecursiveOfType(InlineString))

Would be nice to make serialization of inlinestrings more compatible!

@KristofferC
Copy link
Member

This does not seem specific to InlineStrings but is in fact the case for all isbits objects (JuliaLang/julia#11135) so based on that I think this can be closed and it should instead be fixed upstream.

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