-
Notifications
You must be signed in to change notification settings - Fork 88
Refactor writing to pointers #1531
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
base: master
Are you sure you want to change the base?
Changes from all commits
9485208
65e1ccc
87a979a
c4d96e8
c7199a0
7816bed
7d87b35
a30fbfc
6843784
3a1f1bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -585,9 +585,9 @@ struct | |
| if not (VD.is_immediate_type t) then M.info ~category:Unsound "Unknown value in %s could be an escaped pointer address!" description; empty | ||
| | Bot -> (*M.debug ~category:Analyzer "A bottom value when computing reachable addresses!";*) empty | ||
| | Address adrs when AD.is_top adrs -> | ||
| M.info ~category:Unsound "Unknown address in %s has escaped." description; AD.remove Addr.NullPtr adrs (* return known addresses still to be a bit more sane (but still unsound) *) | ||
| M.info ~category:Unsound "Unknown address in %s has escaped." description; adrs (* return known addresses still to be a bit more sane (but still unsound) *) | ||
| (* The main thing is to track where pointers go: *) | ||
| | Address adrs -> AD.remove Addr.NullPtr adrs | ||
| | Address adrs -> adrs | ||
| (* Unions are easy, I just ingore the type info. *) | ||
| | Union (f,e) -> reachable_from_value ask e t description | ||
| (* For arrays, we ask to read from an unknown index, this will cause it | ||
|
|
@@ -1567,13 +1567,9 @@ struct | |
| | Top -> Queries.Result.top q | ||
| | Bot -> Queries.Result.bot q (* TODO: remove *) | ||
| | Address a -> | ||
| let a' = AD.remove Addr.UnknownPtr a in (* run reachable_vars without unknown just to be safe: TODO why? *) | ||
| let addrs = reachable_vars ~man man.local [a'] in | ||
| let addrs' = List.fold_left (AD.join) (AD.empty ()) addrs in | ||
| if AD.may_be_unknown a then | ||
| AD.add UnknownPtr addrs' (* add unknown back *) | ||
| else | ||
| addrs' | ||
| [a] | ||
| |> reachable_vars ~man man.local | ||
| |> List.fold_left (AD.join) (AD.empty ()) | ||
| | Int i -> | ||
| begin match Cilfacade.typeOf e with | ||
| | t when Cil.isPointerType t -> AD.of_int i (* integer used as pointer *) | ||
|
|
@@ -1814,23 +1810,20 @@ struct | |
| let set ~(man: _ man) ?invariant ?blob_destructive ?lval_raw ?rval_raw ?t_override (st: store) (lval: AD.t) (lval_type: Cil.typ) (value: value) : store = | ||
| let lval_raw = (Option.map (fun x -> Lval x) lval_raw) in | ||
| if M.tracing then M.tracel "set" "lval: %a\nvalue: %a\nstate: %a" AD.pretty lval VD.pretty value CPA.pretty st.cpa; | ||
| let update_one x store = | ||
| Option.map_default (fun x -> set_mval ~man ?invariant ?blob_destructive ?lval_raw ?rval_raw ?t_override store x lval_type value) store (Addr.to_mval x) | ||
| in try | ||
| (* We start from the current state and an empty list of global deltas, | ||
| * and we assign to all the the different possible places: *) | ||
| let nst = AD.fold update_one lval st in | ||
| (* if M.tracing then M.tracel "set" "new state1 %a" CPA.pretty nst; *) | ||
| (* If the address was definite, then we just return it. If the address | ||
| * was ambiguous, we have to join it with the initial state. *) | ||
| let nst = if AD.cardinal lval > 1 then D.join st nst else nst in | ||
| (* if M.tracing then M.tracel "set" "new state2 %a" CPA.pretty nst; *) | ||
| nst | ||
| with | ||
| (* If any of the addresses are unknown, we ignore it!?! *) | ||
| | SetDomain.Unsupported x -> | ||
| (* if M.tracing then M.tracel "set" "set got an exception '%s'" x; *) | ||
| M.info ~category:Unsound "Assignment to unknown address, assuming no write happened."; st | ||
| let update_one (x : Addr.t) store = | ||
| match x with | ||
| | Addr x -> set_mval ~man ?invariant ?blob_destructive ?lval_raw ?rval_raw ?t_override store x lval_type value | ||
| | NullPtr -> | ||
| begin match get_string "sem.null-pointer.dereference" with | ||
| | "assume_none" -> D.bot () | ||
| | "assume_top" -> store | ||
| | _ -> assert false | ||
| end | ||
| | UnknownPtr | ||
| | StrPtr _ -> store | ||
| in | ||
| assert (not @@ AD.is_empty lval); | ||
| AD.fold (fun addr acc -> D.join (update_one addr st) acc) lval (D.bot ()) | ||
|
Comment on lines
+1825
to
+1826
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The old CI runs seem to be gone, but I now merged master into this and locally at least two malloc_null tests fail. I suppose turning a |
||
|
|
||
| let set_many ~man (st: store) lval_value_list: store = | ||
| (* Maybe this can be done with a simple fold *) | ||
|
|
@@ -2111,14 +2104,14 @@ struct | |
| collect_funargs ~man ~warn st exps | ||
| else ( | ||
| let mpt e = match eval_rv_address ~man st e with | ||
| | Address a -> AD.remove NullPtr a | ||
| | Address a -> a | ||
| | _ -> AD.empty () | ||
| in | ||
| List.map mpt exps | ||
| ) | ||
|
|
||
| let invalidate ~(must: bool) ?(deep=true) ~man (st:store) (exps: exp list): store = | ||
| if M.tracing && exps <> [] then M.tracel "invalidate" "Will invalidate expressions [%a]" (d_list ", " d_plainexp) exps; | ||
| if M.tracing && exps <> [] then M.tracel "invalidate" "Will invalidate expressions [%a]" (d_list ", " d_exp) exps; | ||
| if exps <> [] then M.info ~category:Imprecise "Invalidating expressions: %a" (d_list ", " d_exp) exps; | ||
| (* To invalidate a single address, we create a pair with its corresponding | ||
| * top value. *) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| #include<goblint.h> | ||
| #include <wchar.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| int g = 8; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.