Skip to content

Commit 98a779e

Browse files
Merge branch 'master' into master
2 parents c1805ea + 39dc63e commit 98a779e

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

src/analyses/memOutOfBounds.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct
127127
`Top)
128128

129129
let get_ptr_deref_type ptr_typ =
130-
match ptr_typ with
130+
match Cil.unrollType ptr_typ with
131131
| TPtr (t, _) -> Some t
132132
| _ -> None
133133

@@ -279,10 +279,10 @@ struct
279279
M.warn "Size of lval dereference expression %a is bot. Out-of-bounds memory access may occur" d_exp e)
280280
| `Lifted es ->
281281
let casted_es = ID.cast_to (Cilfacade.ptrdiff_ikind ()) es in
282-
let one = intdom_of_int 1 in
283-
let casted_es = ID.sub casted_es one in
284-
let casted_offs = ID.cast_to (Cilfacade.ptrdiff_ikind ()) offs_intdom in
282+
let casted_offs = ID.div (ID.cast_to (Cilfacade.ptrdiff_ikind ()) offs_intdom) (ID.of_int (Cilfacade.ptrdiff_ikind ()) (Z.of_int 8)) in
285283
let ptr_size_lt_offs =
284+
let one = intdom_of_int 1 in
285+
let casted_es = ID.sub casted_es one in
286286
begin try ID.lt casted_es casted_offs
287287
with IntDomain.ArithmeticOnIntegerBot _ -> ID.bot_of @@ Cilfacade.ptrdiff_ikind ()
288288
end

src/cdomain/value/cdomains/valueDomain.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ struct
349349
************************************************************)
350350

351351
(* is a cast t1 to t2 invertible, i.e., content-preserving in general? *)
352-
let is_statically_safe_cast t2 t1 = match t2, t1 with
352+
let is_statically_safe_cast t2 t1 = match unrollType t2, unrollType t1 with
353353
(*| TPtr _, t -> bitsSizeOf t <= bitsSizeOf !upointType
354354
| t, TPtr _ -> bitsSizeOf t >= bitsSizeOf !upointType*)
355355
| TFloat (fk1,_), TFloat (fk2,_) when fk1 = fk2 -> true
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// PARAM: --set ana.malloc.unique_address_count 2
2+
// Extracted (using creduce) from SV-COMP task list-simple/dll2c_remove_all.i
3+
#include <stdlib.h>
4+
#include <goblint.h>
5+
6+
typedef struct node {
7+
struct node *next;
8+
struct node *prev;
9+
} * DLL;
10+
11+
void dll_remove(DLL *head) {
12+
DLL temp = (*head)->next;
13+
if (temp == *head) {
14+
__goblint_check(temp == *head);
15+
__goblint_check(temp != *head); // FAIL
16+
free(*head);
17+
}
18+
else {
19+
__goblint_check(temp != *head);
20+
__goblint_check(temp == *head); // FAIL
21+
(*head)->prev->next = temp;
22+
free(*head);
23+
*head = temp;
24+
}
25+
}
26+
main() {
27+
DLL s = malloc(sizeof(struct node));
28+
s->next = s->prev = malloc(sizeof(struct node));
29+
30+
dll_remove(&s);
31+
dll_remove(&s);
32+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// PARAM: --set ana.activated[+] memOutOfBounds
2+
// Minimized version of SV-COMP task list-simple/dll2c_append_equal.i
3+
#include <stdlib.h>
4+
5+
typedef struct node {
6+
struct node *next;
7+
struct node *prev;
8+
int data;
9+
} *DLL;
10+
11+
int main(void) {
12+
DLL temp = (DLL) malloc(sizeof(struct node));
13+
temp->next = NULL; // NOWARN
14+
temp->prev = NULL; // NOWARN
15+
temp->data = 1; // NOWARN
16+
return temp;
17+
}

0 commit comments

Comments
 (0)