Skip to content

Commit 1aad902

Browse files
Merge pull request diffblue#391 from diffblue/CBMC_merge_2018-04-25
[SEC-367] CBMC merge 2018-04-25
2 parents 6171f06 + 9ec8edd commit 1aad902

File tree

193 files changed

+2624
-924
lines changed

Some content is hidden

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

193 files changed

+2624
-924
lines changed

cbmc/.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ NamespaceIndentation: None
8484
PenaltyBreakString: 10000
8585
PointerAlignment: Right
8686
ReflowComments: 'false'
87-
SortIncludes: 'false'
87+
SortIncludes: 'true'
8888
SpaceAfterCStyleCast: 'false'
8989
SpaceBeforeAssignmentOperators: 'true'
9090
SpaceBeforeParens: Never
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct some_struct
2+
{
3+
int some_field;
4+
} array[10];
5+
6+
int main()
7+
{
8+
array[0].some_field=1;
9+
array->some_field=1;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifdef __GNUC__
2+
// example extracted from SV-COMP's ldv-linux-3.4-simple/
3+
// 32_7_cpp_false-unreach-call_single_drivers-net-phy-dp83640
4+
static int __attribute__((__section__(".init.text")))
5+
__attribute__((no_instrument_function)) dp83640_init(void)
6+
{
7+
return 0;
8+
}
9+
int init_module(void) __attribute__((alias("dp83640_init")));
10+
#endif
11+
12+
int main()
13+
{
14+
#ifdef __GNUC__
15+
dp83640_init();
16+
#endif
17+
return 0;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

cbmc/regression/ansi-c/gcc_attributes9/main.c

+12
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ const char* __attribute__((section("s"))) __attribute__((weak)) bar();
1111
volatile int __attribute__((__section__(".init.data1"))) txt_heap_base1;
1212
volatile int __attribute__((__section__(".init.data3"))) txt_heap_base, __attribute__((__section__(".init.data4"))) txt_heap_size;
1313

14+
int __attribute__((__section__(".init.text"))) __attribute__((__cold__))
15+
__alloc_bootmem_huge_page(void *h);
16+
int __attribute__((__section__(".init.text"))) __attribute__((__cold__))
17+
alloc_bootmem_huge_page(void *h);
18+
int alloc_bootmem_huge_page(void *h)
19+
__attribute__((weak, alias("__alloc_bootmem_huge_page")));
20+
int __alloc_bootmem_huge_page(void *h)
21+
{
22+
return 1;
23+
}
1424
#endif
1525

1626
int main()
1727
{
1828
#ifdef __GNUC__
29+
int r = alloc_bootmem_huge_page(0);
30+
1931
static int __attribute__((section(".data.unlikely"))) __warned;
2032
__warned=1;
2133
return __warned;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
int bar()
2+
{
3+
return 0;
4+
}
5+
6+
int bar2()
7+
{
8+
return 0;
9+
}
10+
11+
int main()
12+
{
13+
unsigned x = foo();
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
void bar()
2+
{
3+
}
4+
5+
void bar2()
6+
{
7+
}
8+
9+
unsigned foo()
10+
{
11+
return 0;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
other.c
4+
^EXIT=(64|1)$
5+
^SIGNAL=0$
6+
^CONVERSION ERROR$
7+
error: conflicting function declarations `bar'
8+
error: conflicting function declarations `bar2'
9+
--
10+
^warning: ignoring
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class AssertionIssue {
2+
3+
public static void throwAssertion() {
4+
throw new AssertionError("Something went terribly wrong.", new ThrowableAssertion());
5+
}
6+
7+
public static class ThrowableAssertion extends Throwable {
8+
@Override
9+
public String getMessage() {
10+
return "How did we get here?";
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
AssertionIssue.class
3+
--function AssertionIssue.throwAssertion
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class TestClass {
2+
public static void f(int y) {
3+
float[][] a1 = new float[y][3];
4+
int j = 0;
5+
a1[j][0] = 34.5f;
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
TestClass.class
3+
--function TestClass.f --cover location --unwind 2
4+
Source GOTO statement: .*
5+
(^ exception: Can't convert byte_extraction|Nested exception printing not supported on Windows)
6+
^EXIT=6$
7+
--
8+
--
9+
The exception thrown in this test is the symptom of a bug; the purpose of this
10+
test is the validate the output of that exception
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class Test {
2+
3+
interface factory_intf {
4+
public intf getintf();
5+
}
6+
7+
interface intf {
8+
public void f();
9+
}
10+
11+
public static void main(factory_intf i) { i.getintf().f(); }
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE symex-driven-lazy-loading-expected-failure
2+
Test.class
3+
--lazy-methods --show-goto-functions --verbosity 10 --function Test.main
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^CI lazy methods: elaborate java::Test\$intf\.f:\(\)V$
7+
Test\$intf\.f:\(\)V\(\);$
8+
--
9+
--
10+
This doesn't work under symex-driven lazy loading because it is incompatible with --lazy-methods

cbmc/regression/cbmc-java/virtual7/test.desc

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ test.class
33
--show-goto-functions --function test.main
44
^EXIT=0$
55
^SIGNAL=0$
6-
IF.*"java::C".*THEN GOTO
7-
IF.*"java::D".*THEN GOTO
6+
IF.*"java::B".*THEN GOTO
7+
IF.*"java::E".*THEN GOTO
88
IF.*"java::A".*THEN GOTO
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <stdlib.h>
2+
#include <assert.h>
3+
4+
#pragma pack(1)
5+
struct A
6+
{
7+
unsigned char a;
8+
unsigned char b : 2;
9+
unsigned char c : 2;
10+
unsigned char d;
11+
};
12+
13+
struct B
14+
{
15+
unsigned char a;
16+
unsigned char b : 2;
17+
unsigned char c;
18+
unsigned char d : 2;
19+
};
20+
21+
struct C
22+
{
23+
unsigned char a;
24+
unsigned char b : 4;
25+
unsigned char c : 4;
26+
unsigned char d;
27+
};
28+
#pragma pack()
29+
30+
int main(void)
31+
{
32+
assert(sizeof(struct A) == 3);
33+
struct A *p = malloc(3);
34+
assert((unsigned char *)p + 2 == &(p->d));
35+
p->c = 3;
36+
if(p->c != 3)
37+
{
38+
free(p);
39+
}
40+
free(p);
41+
42+
assert(sizeof(struct B) == 4);
43+
struct B *pb = malloc(4);
44+
assert((unsigned char *)pb + 2 == &(pb->c));
45+
free(pb);
46+
47+
assert(sizeof(struct C) == 3);
48+
struct C *pc = malloc(3);
49+
assert((unsigned char *)pc + 2 == &(pc->d));
50+
free(pc);
51+
52+
return 0;
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--pointer-check --bounds-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
other.c
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int foo();
2+
3+
int main()
4+
{
5+
return foo();
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int foo()
2+
{
3+
return 1;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
@args
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
int x;
3+
4+
void func0()
5+
{
6+
func0();
7+
}
8+
9+
void func1()
10+
{
11+
x = 1;
12+
}
13+
14+
void func2()
15+
{
16+
x = 2;
17+
func3();
18+
}
19+
20+
void func3()
21+
{
22+
x = 3;
23+
}
24+
25+
void func4(int b)
26+
{
27+
x = 4;
28+
if(b)
29+
{
30+
func5(0);
31+
}
32+
}
33+
34+
void func5(int b)
35+
{
36+
x = 5;
37+
func4(b);
38+
}
39+
40+
void func6()
41+
{
42+
x = 6;
43+
}
44+
45+
void func7(int b)
46+
{
47+
x = 7;
48+
if(b)
49+
{
50+
func8(0);
51+
}
52+
}
53+
54+
void func8(int b)
55+
{
56+
x = 8;
57+
func7(b);
58+
}
59+
60+
void func9()
61+
{
62+
x = 9;
63+
funca();
64+
}
65+
66+
void funca()
67+
{
68+
x = 10;
69+
func9();
70+
}
71+
72+
73+
74+
int main()
75+
{
76+
func1();
77+
func2();
78+
func4(1);
79+
80+
return 0;
81+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CORE
2+
main.c
3+
--call-graph
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^main -> func2$
7+
^main -> func1$
8+
^main -> func4$
9+
^funca -> func9$
10+
^func9 -> funca$
11+
^func8 -> func7$
12+
^func7 -> func8$
13+
^__CPROVER__start -> __CPROVER_initialize$
14+
^__CPROVER__start -> main$
15+
^func2 -> func3$
16+
^func0 -> func0$
17+
^func4 -> func5$
18+
^func5 -> func4$
19+
--
20+
^warning: ignoring

0 commit comments

Comments
 (0)