Skip to content

Commit ebd5343

Browse files
committed
More unwinding should not yield additional assertion failures
See https://groups.google.com/d/msg/cprover-support/FQHJYskRRuI/mKo7EQq9BAAJ for discussion and the source of this regression test. The problem is addressed by the prior commits on this branch/pull request.
1 parent cc659c9 commit ebd5343

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

regression/cbmc/Malloc24/main.c

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <stdlib.h>
2+
3+
struct node
4+
{
5+
int value;
6+
struct node *next;
7+
};
8+
9+
struct list
10+
{
11+
int size;
12+
struct node *head;
13+
};
14+
15+
void removeLast(struct list * l)
16+
{
17+
int index = l->size - 1;
18+
struct node **current;
19+
for(current = &(l->head); index && *current; index--)
20+
current = &(*current)->next;
21+
*current = (*current)->next;
22+
l->size--;
23+
}
24+
25+
int main () {
26+
//build a 2-nodes list
27+
struct node *n0 = malloc(sizeof(struct node));
28+
struct node *n1 = malloc(sizeof(struct node));
29+
struct list *l = malloc(sizeof(struct list));
30+
l->size = 2;
31+
l->head = n0;
32+
33+
n0->next=n1;
34+
n1->next=NULL;
35+
36+
//remove last node from list
37+
38+
//this passes
39+
// struct node **current = &(l->head);
40+
// current = &(*current)->next;
41+
// *current = (*current)->next;
42+
// l->size--;
43+
//this doesn't
44+
removeLast(l);
45+
46+
__CPROVER_assert(n0->next == NULL , "not NULL");
47+
}

regression/cbmc/Malloc24/test.desc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--unwind 4 --pointer-check --unwinding-assertions
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)