|
|
@ -291,14 +291,16 @@ module AccessSnapshot = struct
|
|
|
|
let make_from_snapshot access {lock; thread; ownership_precondition} =
|
|
|
|
let make_from_snapshot access {lock; thread; ownership_precondition} =
|
|
|
|
(* shouldn't be creating metadata for accesses that are known to be owned; we should discard
|
|
|
|
(* shouldn't be creating metadata for accesses that are known to be owned; we should discard
|
|
|
|
such accesses *)
|
|
|
|
such accesses *)
|
|
|
|
assert (not (OwnershipPrecondition.is_true ownership_precondition)) ;
|
|
|
|
Option.some_if
|
|
|
|
|
|
|
|
(not (OwnershipPrecondition.is_true ownership_precondition))
|
|
|
|
{access; thread; lock; ownership_precondition}
|
|
|
|
{access; thread; lock; ownership_precondition}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let make access lock thread ownership_precondition pdesc =
|
|
|
|
let make access lock thread ownership_precondition pdesc =
|
|
|
|
assert (not (OwnershipPrecondition.is_true ownership_precondition)) ;
|
|
|
|
if not (OwnershipPrecondition.is_true ownership_precondition) then
|
|
|
|
let lock = LocksDomain.is_locked lock || Procdesc.is_java_synchronized pdesc in
|
|
|
|
let lock = LocksDomain.is_locked lock || Procdesc.is_java_synchronized pdesc in
|
|
|
|
{access; lock; thread; ownership_precondition}
|
|
|
|
Some {access; lock; thread; ownership_precondition}
|
|
|
|
|
|
|
|
else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let is_unprotected {thread; lock; ownership_precondition} =
|
|
|
|
let is_unprotected {thread; lock; ownership_precondition} =
|
|
|
@ -321,12 +323,16 @@ module AccessDomain = struct
|
|
|
|
|> Option.value_map ~default:false ~f:(fun ((v, _), _) -> should_skip_var v)
|
|
|
|
|> Option.value_map ~default:false ~f:(fun ((v, _), _) -> should_skip_var v)
|
|
|
|
in
|
|
|
|
in
|
|
|
|
if skip then astate else add s astate
|
|
|
|
if skip then astate else add s astate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let add_opt snapshot_opt astate =
|
|
|
|
|
|
|
|
Option.fold snapshot_opt ~init:astate ~f:(fun acc s -> add s acc)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
module OwnershipAbstractValue = struct
|
|
|
|
module OwnershipAbstractValue = struct
|
|
|
|
type t = Owned | OwnedIf of IntSet.t | Unowned [@@deriving compare]
|
|
|
|
type t = OwnedIf of IntSet.t | Unowned [@@deriving compare]
|
|
|
|
|
|
|
|
|
|
|
|
let owned = Owned
|
|
|
|
let owned = OwnedIf IntSet.empty
|
|
|
|
|
|
|
|
|
|
|
|
let unowned = Unowned
|
|
|
|
let unowned = Unowned
|
|
|
|
|
|
|
|
|
|
|
@ -340,12 +346,8 @@ module OwnershipAbstractValue = struct
|
|
|
|
true (* Unowned is top *)
|
|
|
|
true (* Unowned is top *)
|
|
|
|
| Unowned, _ ->
|
|
|
|
| Unowned, _ ->
|
|
|
|
false
|
|
|
|
false
|
|
|
|
| Owned, _ ->
|
|
|
|
|
|
|
|
true (* Owned is bottom *)
|
|
|
|
|
|
|
|
| OwnedIf s1, OwnedIf s2 ->
|
|
|
|
| OwnedIf s1, OwnedIf s2 ->
|
|
|
|
IntSet.subset s1 s2
|
|
|
|
IntSet.subset s1 s2
|
|
|
|
| OwnedIf _, Owned ->
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let join astate1 astate2 =
|
|
|
|
let join astate1 astate2 =
|
|
|
@ -354,8 +356,6 @@ module OwnershipAbstractValue = struct
|
|
|
|
match (astate1, astate2) with
|
|
|
|
match (astate1, astate2) with
|
|
|
|
| _, Unowned | Unowned, _ ->
|
|
|
|
| _, Unowned | Unowned, _ ->
|
|
|
|
Unowned
|
|
|
|
Unowned
|
|
|
|
| astate, Owned | Owned, astate ->
|
|
|
|
|
|
|
|
astate
|
|
|
|
|
|
|
|
| OwnedIf s1, OwnedIf s2 ->
|
|
|
|
| OwnedIf s1, OwnedIf s2 ->
|
|
|
|
OwnedIf (IntSet.union s1 s2)
|
|
|
|
OwnedIf (IntSet.union s1 s2)
|
|
|
|
|
|
|
|
|
|
|
@ -366,11 +366,11 @@ module OwnershipAbstractValue = struct
|
|
|
|
| Unowned ->
|
|
|
|
| Unowned ->
|
|
|
|
F.pp_print_string fmt "Unowned"
|
|
|
|
F.pp_print_string fmt "Unowned"
|
|
|
|
| OwnedIf s ->
|
|
|
|
| OwnedIf s ->
|
|
|
|
|
|
|
|
if IntSet.is_empty s then F.pp_print_string fmt "Owned"
|
|
|
|
|
|
|
|
else
|
|
|
|
F.fprintf fmt "OwnedIf%a"
|
|
|
|
F.fprintf fmt "OwnedIf%a"
|
|
|
|
(PrettyPrintable.pp_collection ~pp_item:Int.pp)
|
|
|
|
(PrettyPrintable.pp_collection ~pp_item:Int.pp)
|
|
|
|
(IntSet.elements s)
|
|
|
|
(IntSet.elements s)
|
|
|
|
| Owned ->
|
|
|
|
|
|
|
|
F.pp_print_string fmt "Owned"
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
module OwnershipDomain = struct
|
|
|
|
module OwnershipDomain = struct
|
|
|
@ -387,7 +387,7 @@ module OwnershipDomain = struct
|
|
|
|
OwnershipAbstractValue.Unowned
|
|
|
|
OwnershipAbstractValue.Unowned
|
|
|
|
in
|
|
|
|
in
|
|
|
|
match find access_path astate with
|
|
|
|
match find access_path astate with
|
|
|
|
| (OwnershipAbstractValue.Owned | OwnedIf _) as v ->
|
|
|
|
| OwnershipAbstractValue.OwnedIf _ as v ->
|
|
|
|
v
|
|
|
|
v
|
|
|
|
| OwnershipAbstractValue.Unowned ->
|
|
|
|
| OwnershipAbstractValue.Unowned ->
|
|
|
|
keep_looking access_path astate
|
|
|
|
keep_looking access_path astate
|
|
|
@ -426,7 +426,7 @@ module OwnershipDomain = struct
|
|
|
|
in
|
|
|
|
in
|
|
|
|
let ret_ownership_wrt_actuals =
|
|
|
|
let ret_ownership_wrt_actuals =
|
|
|
|
match return_ownership with
|
|
|
|
match return_ownership with
|
|
|
|
| OwnershipAbstractValue.Owned | Unowned ->
|
|
|
|
| OwnershipAbstractValue.Unowned ->
|
|
|
|
return_ownership
|
|
|
|
return_ownership
|
|
|
|
| OwnershipAbstractValue.OwnedIf formal_indexes ->
|
|
|
|
| OwnershipAbstractValue.OwnedIf formal_indexes ->
|
|
|
|
IntSet.fold get_ownership formal_indexes OwnershipAbstractValue.owned
|
|
|
|
IntSet.fold get_ownership formal_indexes OwnershipAbstractValue.owned
|
|
|
@ -595,4 +595,4 @@ let pp fmt {threads; locks; accesses; ownership; attribute_map} =
|
|
|
|
let add_unannotated_call_access pname loc pdesc (astate : t) =
|
|
|
|
let add_unannotated_call_access pname loc pdesc (astate : t) =
|
|
|
|
let access = TraceElem.make_unannotated_call_access pname loc in
|
|
|
|
let access = TraceElem.make_unannotated_call_access pname loc in
|
|
|
|
let snapshot = AccessSnapshot.make access astate.locks astate.threads False pdesc in
|
|
|
|
let snapshot = AccessSnapshot.make access astate.locks astate.threads False pdesc in
|
|
|
|
{astate with accesses= AccessDomain.add snapshot astate.accesses}
|
|
|
|
{astate with accesses= AccessDomain.add_opt snapshot astate.accesses}
|
|
|
|