From d22e08cf823de4e48af493f3d0ffe178bc95e4c6 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 18 Feb 2021 07:49:03 -0800 Subject: [PATCH] [impurity] sort edges before comparing them Summary: This was a correctness issue as nothing guarantees that bindings are in a specific order. The following commit violates that assumptions and made the impurity tests fail without this change. Reviewed By: ezgicicek Differential Revision: D26488379 fbshipit-source-id: e9cc41147 --- infer/src/checkers/impurity.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/infer/src/checkers/impurity.ml b/infer/src/checkers/impurity.ml index f4e38415b..341249e9e 100644 --- a/infer/src/checkers/impurity.ml +++ b/infer/src/checkers/impurity.ml @@ -10,7 +10,7 @@ module L = Logging open PulseBasicInterface open PulseDomainInterface -let debug fmt = L.(debug Analysis Verbose fmt) +let debug fmt = L.debug Analysis Verbose fmt let get_matching_dest_addr_opt ~edges_pre ~edges_post : (BaseMemory.Access.t * AbstractValue.t) list option = @@ -20,8 +20,9 @@ let get_matching_dest_addr_opt ~edges_pre ~edges_post : if AbstractValue.equal addr_dest_pre addr_dest_post then Option.map acc ~f:(fun acc -> (access, addr_dest_pre) :: acc) else None ) - (BaseMemory.Edges.bindings edges_pre) - (BaseMemory.Edges.bindings edges_post) + (BaseMemory.Edges.bindings edges_pre |> List.sort ~compare:[%compare: BaseMemory.Access.t * _]) + ( BaseMemory.Edges.bindings edges_post + |> List.sort ~compare:[%compare: BaseMemory.Access.t * _] ) with | Unequal_lengths -> debug "Mismatch in pre and post.\n" ;