Skip to content

Commit

Permalink
fix serialization of multiple global bindings to the same object in a…
Browse files Browse the repository at this point in the history
… closure (JuliaLang#21700)

* fix serialization of multiple global bindings to the same object in a closure
  • Loading branch information
amitmurthy authored May 5, 2017
1 parent 9beece6 commit 3930eef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/distributed/clusterserialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function syms_2b_sent(s::ClusterSerializer, identifier)
oid = object_id(v)
if haskey(s.glbs_sent, oid)
# We have sent this object before, see if it has changed.
s.glbs_sent[oid] != hash(v) && push!(lst, sym)
s.glbs_sent[oid] != hash(sym, hash(v)) && push!(lst, sym)
else
push!(lst, sym)
end
Expand Down Expand Up @@ -143,7 +143,7 @@ function serialize_global_from_main(s::ClusterSerializer, sym)
end
end
end
record_v && (s.glbs_sent[oid] = hash(v))
record_v && (s.glbs_sent[oid] = hash(sym, hash(v)))

serialize(s, isconst(Main, sym))
serialize(s, v)
Expand Down
7 changes: 7 additions & 0 deletions test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,13 @@ for i in 1:5
@test remotecall_fetch(()->v2, id_other) == v2
end

# Different global bindings to the same object
global v3 = ones(10)
global v4 = v3
@test remotecall_fetch(()->v3, id_other) == remotecall_fetch(()->v4, id_other)
@test remotecall_fetch(()->isdefined(Main, :v3), id_other)
@test remotecall_fetch(()->isdefined(Main, :v4), id_other)

# Test that a global is not being repeatedly serialized when
# a) referenced multiple times in the closure
# b) hash value has not changed.
Expand Down

0 comments on commit 3930eef

Please sign in to comment.