Segfault during deserialize

The problem has been resolved. It’s not related to Julia.


I have a C++ program with Julia embedded. Basically, I have an object of type Vector{Dict{Int32 Int64}}. I serialized it in one process and send it to another process. I got a segmentation fault when I tried to deserialize the received bytes.

My code for serializing and deserializing the object is as below. They are called from the C++ code. I verified that the length of the serialized bytes on the sending and receiving end are the same.

According to address sanitizer, it seems the deserialize function attempts to read past the valid length of the array.

function serialize_partition(partition)::Vector{UInt8}
    buffer = IOBuffer()
    serialize(buffer, partition)
    return take!(buffer)
end
function deserialize_partition(serialized_bytes::Vector{UInt8})
    buffer = IOBuffer(serialized_bytes)
    partition = deserialize(buffer)
    return partition
end