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

fix #39895, crash from deserialized closure using the shared method table #39916

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stdlib/Serialization/src/Serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,8 @@ function deserialize_typename(s::AbstractSerializer, number)
tn.mt.kwsorter = kws
end
end
elseif makenew
tn.mt = Symbol.name.mt
end
return tn::Core.TypeName
end
Expand Down
15 changes: 15 additions & 0 deletions stdlib/Serialization/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,18 @@ let s = join(rand('a':'z', 1024)), io = IOBuffer()
s2 = deserialize(io)
@test Base.summarysize(s2) < 2*sizeof(s)
end

# issue #39895
@eval Main begin
using Test, Serialization
let g = gensym(:g)
closure = eval(:(f -> $g(x) = f(x)))
inc(x) = x + 1
b = IOBuffer()
serialize(b, closure(inc))
seekstart(b)
f = deserialize(b)
# this should not crash
@test_broken f(1) == 2
end
end