From 2126b6716357ceae0177bd857560ad0634d56449 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 19 Feb 2024 22:23:59 +0000 Subject: [PATCH] [Serialization] fix format bug for pre_13 code pre_13 would fail to read the max_world field, resulting in the stream getting desynchronized and corrupted. Add some type-asserts to help detect that error earlier. --- stdlib/Serialization/src/Serialization.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stdlib/Serialization/src/Serialization.jl b/stdlib/Serialization/src/Serialization.jl index 4fa6274554be0..7f122142c1fff 100644 --- a/stdlib/Serialization/src/Serialization.jl +++ b/stdlib/Serialization/src/Serialization.jl @@ -1214,24 +1214,25 @@ function deserialize(s::AbstractSerializer, ::Type{CodeInfo}) deserialize(s) # rettype ci.parent = deserialize(s) world_or_edges = deserialize(s) - pre_13 = isa(world_or_edges, Integer) + pre_13 = isa(world_or_edges, Union{UInt, Int}) if pre_13 - ci.min_world = world_or_edges + ci.min_world = reinterpret(UInt, world_or_edges) + ci.max_world = reinterpret(UInt, deserialize(s)) else ci.edges = world_or_edges - ci.min_world = reinterpret(UInt, deserialize(s)) - ci.max_world = reinterpret(UInt, deserialize(s)) + ci.min_world = deserialize(s)::UInt + ci.max_world = deserialize(s)::UInt end else ci.parent = deserialize(s) ci.method_for_inference_limit_heuristics = deserialize(s) ci.edges = deserialize(s) - ci.min_world = reinterpret(UInt, deserialize(s)) - ci.max_world = reinterpret(UInt, deserialize(s)) + ci.min_world = deserialize(s)::UInt + ci.max_world = deserialize(s)::UInt end end if format_version(s) <= 26 - deserialize(s) # inferred + deserialize(s)::Bool # inferred end if format_version(s) < 22 inlining_cost = deserialize(s)