Skip to content

Commit 6aa1f00

Browse files
Merge pull request #120 from viktormalik/master
Improvements to the shape abstract domain and to memory safety analysis
2 parents af68bb2 + 215ab5d commit 6aa1f00

File tree

79 files changed

+2932
-451
lines changed

Some content is hidden

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

79 files changed

+2932
-451
lines changed

regression/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
DIRS = heap nontermination termination kiki \
2-
preconditions interprocedural invariants
1+
DIRS = nontermination \
2+
termination \
3+
kiki \
4+
preconditions \
5+
interprocedural \
6+
invariants \
7+
heap \
8+
heap-data \
9+
memsafety
310

411
test:
512
$(foreach var,$(DIRS), make -C $(var) test || exit 1;)

regression/heap-data/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
default: tests.log
2+
3+
FLAGS = --verbosity 10
4+
5+
test:
6+
@../test.pl -p -c "../../../src/2ls/2ls $(FLAGS)"
7+
8+
tests.log: ../test.pl
9+
@../test.pl -p -c "../../../src/2ls/2ls $(FLAGS)"
10+
11+
show:
12+
@for dir in *; do \
13+
if [ -d "$$dir" ]; then \
14+
vim -o "$$dir/*.c" "$$dir/*.out"; \
15+
fi; \
16+
done;
17+
18+
clean:
19+
@rm -f *.log
20+
@for dir in *; do rm -f $$dir/*.out; done;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
extern int __VERIFIER_nondet_int();
2+
extern void __VERIFIER_error() __attribute__ ((__noreturn__));
3+
4+
#include <stdlib.h>
5+
6+
#define APPEND(l,i) {i->next=l; l=i;}
7+
8+
typedef struct node {
9+
struct node *next;
10+
int event1;
11+
int event2;
12+
} Node;
13+
14+
int main() {
15+
Node *l = NULL;
16+
17+
while (__VERIFIER_nondet_int()) {
18+
int ev1 = __VERIFIER_nondet_int();
19+
int ev2 = __VERIFIER_nondet_int();
20+
if (ev1 < 0 || ev1 > 3 || ev2 < 0 || ev2 > 3)
21+
continue;
22+
23+
if (((ev1 == 0) && (ev2 == 2)) || ((ev1 == 1) && (ev2 == 3)) || ((ev1 == 0) && (ev2 == 3)))
24+
continue;
25+
26+
Node *p = malloc(sizeof(*p));
27+
p->event1 = ev1;
28+
p->event2 = ev2;
29+
APPEND(l,p)
30+
}
31+
32+
Node *i = l;
33+
34+
while (i != NULL) {
35+
if (((i->event1 == 1) && (i->event2 == 3)) || ((i->event1 == 0) && (i->event2 == 2)))
36+
__VERIFIER_error();
37+
i = i->next;
38+
}
39+
}
40+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
--heap-values-refine --sympath --inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$

regression/heap-data/cart/main.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
extern int __VERIFIER_nondet_int();
2+
extern void __VERIFIER_error() __attribute__ ((__noreturn__));
3+
4+
#include <stdlib.h>
5+
6+
#define APPEND(l,i) {i->next=l; l=i;}
7+
8+
typedef struct node {
9+
struct node *next;
10+
int stock;
11+
int order;
12+
} Node;
13+
14+
int main() {
15+
Node *l = NULL;
16+
17+
while (__VERIFIER_nondet_int()) {
18+
int stock = __VERIFIER_nondet_int();
19+
if (stock < 0)
20+
continue;
21+
22+
Node *p = malloc(sizeof(*p));
23+
p->stock = stock;
24+
p->order = 0;
25+
APPEND(l,p)
26+
}
27+
28+
Node *i = l;
29+
while (i != NULL) {
30+
int order = __VERIFIER_nondet_int();
31+
if (order < 0 || i->stock < order)
32+
continue;
33+
i->order = order;
34+
i->stock = i->stock;
35+
i = i->next;
36+
}
37+
38+
39+
i = l;
40+
while (i != NULL) {
41+
if (i->order > i->stock)
42+
__VERIFIER_error();
43+
i = i->next;
44+
}
45+
}
46+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
--heap-values-refine --sympath --inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
extern int __VERIFIER_nondet_int();
2+
extern void __VERIFIER_error() __attribute__ ((__noreturn__));
3+
4+
#include <stdlib.h>
5+
6+
#define INTERVAL_SIZE 100
7+
8+
struct node {
9+
int hash;
10+
struct node *next;
11+
};
12+
13+
int hash_fun();
14+
15+
void append_to_list(struct node **list, int hash) {
16+
struct node *node = malloc(sizeof(*node));
17+
node->next = *list;
18+
node->hash = hash;
19+
*list = node;
20+
}
21+
22+
int main() {
23+
struct node *list = NULL;
24+
25+
int base = __VERIFIER_nondet_int();
26+
27+
while (__VERIFIER_nondet_int()) {
28+
if (base >= 0 && base <= 1000000) {
29+
base = base;
30+
int hash = hash_fun();
31+
32+
if (hash > base && hash < base + INTERVAL_SIZE)
33+
append_to_list(&list, hash);
34+
}
35+
}
36+
37+
while (list) {
38+
if (!(list->hash >= base && list->hash < base + INTERVAL_SIZE))
39+
__VERIFIER_error();
40+
list = list->next;
41+
}
42+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
--heap-values-refine --sympath --inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
extern int __VERIFIER_nondet_int();
2+
extern void __VERIFIER_error() __attribute__ ((__noreturn__));
3+
4+
#include <stdlib.h>
5+
#include <limits.h>
6+
7+
#define APPEND(l,i) {i->next=l; l=i;}
8+
9+
typedef struct node {
10+
struct node *next;
11+
int val;
12+
} Node;
13+
14+
int main() {
15+
Node *l = NULL;
16+
int min = INT_MAX, max = -INT_MAX;
17+
18+
while (__VERIFIER_nondet_int()) {
19+
Node *p = malloc(sizeof(*p));
20+
p->val = __VERIFIER_nondet_int();
21+
APPEND(l, p)
22+
23+
if (min > p->val) {
24+
min = p->val;
25+
}
26+
if (max < p->val) {
27+
max = p->val;
28+
}
29+
30+
}
31+
32+
Node *i = l;
33+
while (i != NULL) {
34+
if (i->val < min)
35+
__VERIFIER_error();
36+
if (i->val > max)
37+
__VERIFIER_error();
38+
i = i->next;
39+
}
40+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
--heap-values-refine --sympath --inline
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$

0 commit comments

Comments
 (0)