# Segfault during deserialize

**URL:** <https://discourse.julialang.org/t/segfault-during-deserialize/11256>\
**Category:** General Usage\
**Created:** [May 30, 2018, 6:08am UTC](https://discourse.julialang.org/t/segfault-during-deserialize/11256 "2018-05-30T06:08:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jinliangwei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jinliangwei/32/1929_2.png) [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Post date:** [May 30, 2018, 6:08am UTC](https://discourse.julialang.org/t/segfault-during-deserialize/11256/1 "2018-05-30T06:08:37Z")

</div>

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.

```julia
function serialize_partition(partition)::Vector{UInt8}
    buffer = IOBuffer()
    serialize(buffer, partition)
    return take!(buffer)
end

```

```julia
function deserialize_partition(serialized_bytes::Vector{UInt8})
    buffer = IOBuffer(serialized_bytes)
    partition = deserialize(buffer)
    return partition
end

```
