Skip to content

Commit 8a079a4

Browse files
committed
Merge branch 'master' into yaml-witness-default
2 parents a17e50d + 52a3bbb commit 8a079a4

File tree

80 files changed

+2054
-1524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2054
-1524
lines changed

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# GitHub repository language overrides
2+
# https://github.com/github-linguist/linguist/blob/main/docs/overrides.md
3+
4+
# currently only dune-project is classified: https://github.com/github-linguist/linguist/pull/7126
5+
dune linguist-language=dune
6+
dune.inc linguist-language=dune
7+
8+
# avoid misclassification as Standard ML
9+
*.ml linguist-language=ocaml
10+
*.mli linguist-language=ocaml
11+
12+
# cram tests are classified as Raku/Terra/Turing, cram isn't separate language so consider them also dune
13+
*.t linguist-language=dune

goblint.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
9797
# also remember to generate/adjust goblint.opam.locked!
9898
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
9999
pin-depends: [
100-
# published goblint-cil 2.0.5 is currently up-to-date, but pinned for reproducibility
101-
[ "goblint-cil.2.0.5" "git+https://github.com/goblint/cil.git#f5ee39bd344dc74e2a10e407d877e0ddf73c9c6f" ]
100+
# published goblint-cil 2.0.6 is currently up-to-date, but pinned for reproducibility
101+
[ "goblint-cil.2.0.6" "git+https://github.com/goblint/cil.git#8385ab315bc7461f6801af57673c64731bfa036a" ]
102102
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new camlidl release
103103
[ "camlidl.1.12" "git+https://github.com/xavierleroy/camlidl.git#1c1e87e3f56c2c6b3226dd0af3510ef414b462d0" ]
104104
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new apron release

goblint.opam.locked

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ depends: [
6464
"fileutils" {= "0.6.4"}
6565
"fmt" {= "0.9.0"}
6666
"fpath" {= "0.7.3"}
67-
"goblint-cil" {= "2.0.5"}
67+
"goblint-cil" {= "2.0.6"}
6868
"hex" {= "1.5.0"}
6969
"integers" {= "0.7.0"}
7070
"json-data-encoding" {= "1.0.1"}
@@ -139,8 +139,8 @@ post-messages: [
139139
]
140140
pin-depends: [
141141
[
142-
"goblint-cil.2.0.5"
143-
"git+https://github.com/goblint/cil.git#f5ee39bd344dc74e2a10e407d877e0ddf73c9c6f"
142+
"goblint-cil.2.0.6"
143+
"git+https://github.com/goblint/cil.git#8385ab315bc7461f6801af57673c64731bfa036a"
144144
]
145145
[
146146
"camlidl.1.12"

goblint.opam.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# also remember to generate/adjust goblint.opam.locked!
33
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
44
pin-depends: [
5-
# published goblint-cil 2.0.5 is currently up-to-date, but pinned for reproducibility
6-
[ "goblint-cil.2.0.5" "git+https://github.com/goblint/cil.git#f5ee39bd344dc74e2a10e407d877e0ddf73c9c6f" ]
5+
# published goblint-cil 2.0.6 is currently up-to-date, but pinned for reproducibility
6+
[ "goblint-cil.2.0.6" "git+https://github.com/goblint/cil.git#8385ab315bc7461f6801af57673c64731bfa036a" ]
77
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new camlidl release
88
[ "camlidl.1.12" "git+https://github.com/xavierleroy/camlidl.git#1c1e87e3f56c2c6b3226dd0af3510ef414b462d0" ]
99
# pinned for stability (https://github.com/goblint/analyzer/issues/1520), remove after new apron release

gobview

src/analyses/apron/relationAnalysis.apron.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,12 @@ struct
740740
in
741741
({ f } : Queries.ask) in
742742
let rel = RD.assert_inv dummyask rel e false (no_overflow ask e_orig) in (* assume *)
743-
let rel = RD.keep_vars rel (List.map RV.local vars) in (* restrict *)
743+
let rel =
744+
if GobConfig.get_bool "ana.apron.strengthening" then
745+
RD.keep_vars rel (List.map RV.local vars) (* restrict *)
746+
else
747+
rel (* naive unassume: will be homogeneous join below *)
748+
in
744749

745750
(* TODO: parallel write_global? *)
746751
let st =

src/analyses/basePriv.ml

Lines changed: 74 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,47 @@ sig
866866
include AtomicParam
867867
end
868868

869+
module P =
870+
struct
871+
include MustVars
872+
let name () = "P"
873+
end
874+
875+
module Sigma' =
876+
struct
877+
include CPA
878+
let name () = "Protected Changes"
879+
end
880+
881+
module type ProtectionDom =
882+
sig
883+
include Lattice.S
884+
val add: bool -> varinfo -> VD.t -> t -> t
885+
val remove: varinfo -> t -> t
886+
val precise_side: varinfo -> VD.t -> t -> VD.t option
887+
val empty: unit -> t
888+
val getP: t -> P.t
889+
end
890+
891+
module ProtectionCPASide: ProtectionDom =
892+
struct
893+
include P
894+
895+
let add _ x _ t = P.add x t
896+
let precise_side x v t = Some v
897+
let getP t = t
898+
end
899+
900+
module ProtectionChangesOnlySide: ProtectionDom =
901+
struct
902+
include Lattice.Prod (P) (Sigma')
903+
let add invariant x v t = P.add x @@ fst t, if not invariant then Sigma'.add x v @@ snd t else snd t
904+
let remove x t = P.remove x @@ fst t, Sigma'.remove x @@ snd t
905+
let precise_side x v t = Sigma'.find_opt x @@ snd t
906+
let empty () = P.empty (), Sigma'.empty ()
907+
let getP t = fst t
908+
end
909+
869910
(** Protection-Based Reading. *)
870911
module ProtectionBasedV = struct
871912
module VUnprot =
@@ -887,30 +928,24 @@ module ProtectionBasedV = struct
887928
end
888929

889930
(** Protection-Based Reading. *)
890-
module ProtectionBasedPriv (Param: PerGlobalPrivParam)(Wrapper:PrivatizationWrapper): S =
931+
module ProtectionBasedPriv (D: ProtectionDom) (Param: PerGlobalPrivParam)(Wrapper:PrivatizationWrapper): S =
891932
struct
892933
include NoFinalize
893934
include ConfCheck.RequireMutexActivatedInit
894935
open Protection
895936

896-
module P =
897-
struct
898-
include MustVars
899-
let name () = "P"
900-
end
901-
902937
(* W is implicitly represented by CPA domain *)
903-
module D = P
938+
module D = D
904939

905940
module Wrapper = Wrapper (VD)
906941
module G = Wrapper.G
907942
module V = ProtectionBasedV.V
908943

909-
let startstate () = P.empty ()
944+
let startstate () = D.empty ()
910945

911946
let read_global (ask: Queries.ask) getg (st: BaseComponents (D).t) x =
912947
let getg = Wrapper.getg ask getg in
913-
if P.mem x st.priv then
948+
if P.mem x @@ D.getP st.priv then
914949
CPA.find x st.cpa
915950
else if Param.handle_atomic && ask.f MustBeAtomic then
916951
VD.join (CPA.find x st.cpa) (getg (V.unprotected x)) (* Account for previous unpublished unprotected writes in current atomic section. *)
@@ -921,6 +956,7 @@ struct
921956

922957
let write_global ?(invariant=false) (ask: Queries.ask) getg sideg (st: BaseComponents (D).t) x v =
923958
let sideg = Wrapper.sideg ask sideg in
959+
let unprotected = is_unprotected ask x in
924960
if not invariant then (
925961
if not (Param.handle_atomic && ask.f MustBeAtomic) then
926962
sideg (V.unprotected x) v; (* Delay publishing unprotected write in the atomic section. *)
@@ -929,11 +965,11 @@ struct
929965
(* Unlock after invariant will still side effect refined value (if protected) from CPA, because cannot distinguish from non-invariant write since W is implicit. *)
930966
);
931967
if Param.handle_atomic && ask.f MustBeAtomic then
932-
{st with cpa = CPA.add x v st.cpa; priv = P.add x st.priv} (* Keep write local as if it were protected by the atomic section. *)
933-
else if is_unprotected ask x then
968+
{st with cpa = CPA.add x v st.cpa; priv = D.add invariant x v st.priv} (* Keep write local as if it were protected by the atomic section. *)
969+
else if unprotected then
934970
st
935971
else
936-
{st with cpa = CPA.add x v st.cpa; priv = P.add x st.priv}
972+
{st with cpa = CPA.add x v st.cpa; priv = D.add invariant x v st.priv}
937973

938974
let lock ask getg st m = st
939975

@@ -943,16 +979,22 @@ struct
943979
(* TODO: what about G_m globals in cpa that weren't actually written? *)
944980
CPA.fold (fun x v (st: BaseComponents (D).t) ->
945981
if is_protected_by ask m x then ( (* is_in_Gm *)
946-
(* Extra precision in implementation to pass tests:
947-
If global is read-protected by multiple locks,
948-
then inner unlock shouldn't yet publish. *)
949-
if not Param.check_read_unprotected || is_unprotected_without ask ~write:false x m then
950-
sideg (V.protected x) v;
951-
if atomic then
952-
sideg (V.unprotected x) v; (* Publish delayed unprotected write as if it were protected by the atomic section. *)
953-
982+
(* Only apply sides for values that were actually written to globals!
983+
This excludes invariants inferred through guards. *)
984+
begin match D.precise_side x v st.priv with
985+
| Some v -> begin
986+
(* Extra precision in implementation to pass tests:
987+
If global is read-protected by multiple locks,
988+
then inner unlock shouldn't yet publish. *)
989+
if not Param.check_read_unprotected || is_unprotected_without ask ~write:false x m then
990+
sideg (V.protected x) v;
991+
if atomic then
992+
sideg (V.unprotected x) v; (* Publish delayed unprotected write as if it were protected by the atomic section. *)
993+
end
994+
| None -> ()
995+
end;
954996
if is_unprotected_without ask x m then (* is_in_V' *)
955-
{st with cpa = CPA.remove x st.cpa; priv = P.remove x st.priv}
997+
{st with cpa = CPA.remove x st.cpa; priv = D.remove x st.priv}
956998
else
957999
st
9581000
)
@@ -968,7 +1010,7 @@ struct
9681010
if is_global ask x && is_unprotected ask x then (
9691011
sideg (V.unprotected x) v;
9701012
sideg (V.protected x) v; (* must be like enter_multithreaded *)
971-
{st with cpa = CPA.remove x st.cpa; priv = P.remove x st.priv}
1013+
{st with cpa = CPA.remove x st.cpa; priv = D.remove x st.priv}
9721014
)
9731015
else
9741016
st
@@ -1007,7 +1049,7 @@ struct
10071049
if is_global ask x then (
10081050
sideg (V.unprotected x) v;
10091051
sideg (V.protected x) v;
1010-
{st with cpa = CPA.remove x st.cpa; priv = P.remove x st.priv}
1052+
{st with cpa = CPA.remove x st.cpa; priv = D.remove x st.priv}
10111053
)
10121054
else
10131055
st
@@ -2116,19 +2158,21 @@ end
21162158

21172159
let priv_module: (module S) Lazy.t =
21182160
lazy (
2161+
let changes_only = get_bool "ana.base.priv.protection.changes-only" in
2162+
let module ProtDom: ProtectionDom = (val if changes_only then (module ProtectionChangesOnlySide : ProtectionDom) else (module ProtectionCPASide)) in
21192163
let module Priv: S =
21202164
(val match get_string "ana.base.privatization" with
21212165
| "none" -> (module NonePriv: S)
21222166
| "vojdani" -> (module VojdaniPriv: S)
21232167
| "mutex-oplus" -> (module PerMutexOplusPriv)
21242168
| "mutex-meet" -> (module PerMutexMeetPriv)
21252169
| "mutex-meet-tid" -> (module PerMutexMeetTIDPriv (ThreadDigest))
2126-
| "protection" -> (module ProtectionBasedPriv (struct let check_read_unprotected = false let handle_atomic = false end)(NoWrapper))
2127-
| "protection-tid" -> (module ProtectionBasedPriv (struct let check_read_unprotected = false let handle_atomic = false end)(DigestWrapper(ThreadNotStartedDigest)))
2128-
| "protection-atomic" -> (module ProtectionBasedPriv (struct let check_read_unprotected = false let handle_atomic = true end)(NoWrapper)) (* experimental *)
2129-
| "protection-read" -> (module ProtectionBasedPriv (struct let check_read_unprotected = true let handle_atomic = false end)(NoWrapper))
2130-
| "protection-read-tid" -> (module ProtectionBasedPriv (struct let check_read_unprotected = true let handle_atomic = false end)(DigestWrapper(ThreadNotStartedDigest)))
2131-
| "protection-read-atomic" -> (module ProtectionBasedPriv (struct let check_read_unprotected = true let handle_atomic = true end)(NoWrapper)) (* experimental *)
2170+
| "protection" -> (module ProtectionBasedPriv (ProtDom) (struct let check_read_unprotected = false let handle_atomic = false end)(NoWrapper))
2171+
| "protection-tid" -> (module ProtectionBasedPriv (ProtDom) (struct let check_read_unprotected = false let handle_atomic = false end)(DigestWrapper(ThreadNotStartedDigest)))
2172+
| "protection-atomic" -> (module ProtectionBasedPriv (ProtDom) (struct let check_read_unprotected = false let handle_atomic = true end)(NoWrapper)) (* experimental *)
2173+
| "protection-read" -> (module ProtectionBasedPriv (ProtDom) (struct let check_read_unprotected = true let handle_atomic = false end)(NoWrapper))
2174+
| "protection-read-tid" -> (module ProtectionBasedPriv (ProtDom) (struct let check_read_unprotected = true let handle_atomic = false end)(DigestWrapper(ThreadNotStartedDigest)))
2175+
| "protection-read-atomic" -> (module ProtectionBasedPriv (ProtDom) (struct let check_read_unprotected = true let handle_atomic = true end)(NoWrapper)) (* experimental *)
21322176
| "mine" -> (module MinePriv)
21332177
| "mine-nothread" -> (module MineNoThreadPriv)
21342178
| "mine-W" -> (module MineWPriv (struct let side_effect_global_init = true end))

0 commit comments

Comments
 (0)