Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit a526773

Browse files
authored
Merge pull request #1171 from MartinSpiessl/uthash
Add tasks based on the uthash hashing library
2 parents 5a228c3 + 2d1d7a9 commit a526773

File tree

427 files changed

+166383
-0
lines changed

Some content is hidden

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

427 files changed

+166383
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Contains problems from the software system BusyBox.
2+
uthash-2.0.2/*.yml
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Contains problems from the software system BusyBox.
2+
uthash-2.0.2/*.yml
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Contains problems from the software system BusyBox.
2+
uthash-2.0.2/*.yml

c/Termination-Other.set

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ memsafety-ext/*.yml
3434
ldv-memsafety/*.yml
3535
ldv-memsafety-bitfields/*.yml
3636
pthread-atomic/*.yml
37+
uthash-2.0.2/*.yml

c/uthash-2.0.2/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) 2005-2018, Troy D. Hanson http://troydhanson.github.com/uthash/
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
11+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
12+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
13+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
14+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
15+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
17+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
18+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21+

c/uthash-2.0.2/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
LEVEL := ../
2+
3+
include $(LEVEL)/Makefile.config

c/uthash-2.0.2/README.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Tasks in this directory were instrumented and added by Martin Spiessl.
2+
3+
These tasks are test cases for the uthash hashing library,
4+
which is implemented as a preprocessor macro.
5+
6+
As such they are currently purely deterministic, but I think they will still pose a challenge
7+
to verifiers because of their complexity and extensive heap memory handling.
8+
9+
Currently I only took the first 10 test cases with 6 of the 7 possible hash function.
10+
The last hash function murmur hash exploits no-strict-aliasing,
11+
which is undefined behavior and was therefore excluded.
12+
The tests as they were did not cleanup memory properly.
13+
I also added a fixed version of the tasks. For some however,
14+
this fix is insufficient and leads to memory leaks,
15+
in which case a third version of the task is also added.
16+
For test10-3 this is still not enough, so there valid-memtrack
17+
is still violated, I adapted the verdict accordingly.
18+
19+
This makes a total of currently 138 verification tasks.
20+
21+
The .c files were preprocessed with gcc -E -P -m32 $filename
22+
23+
I refrained from formatting the preprocessed files e.g. via clang-formatter because
24+
verifiers should be able to cope with file that have multiple statements in one line.
25+
26+
Have fun with solving these tasks!
27+
28+
The license of uthash is essentially the 1-clause BSD license,
29+
I just copied the LICENSE file from the uthash repository over.
30+
I put the instrumentation code I added to create these tasks
31+
under the same license for convenience.
32+
The version of uthash in these benchmarks is (the tag) 2.0.2

c/uthash-2.0.2/uthash_BER.h

Lines changed: 1228 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include "uthash_BER.h"
2+
#include <stdlib.h> /* malloc */
3+
#include <assert.h>
4+
// BEGIN HARNESS
5+
void reach_error() {
6+
assert(0);
7+
}
8+
9+
void __VERIFIER_assert(int cond) {
10+
if (!cond) {
11+
reach_error();
12+
}
13+
}
14+
int count_int_int = 0;
15+
16+
void test_int_int(int a, int b){
17+
switch (count_int_int++) {
18+
case 0:
19+
__VERIFIER_assert((a == 0) && (b == 0));
20+
break;
21+
case 1:
22+
__VERIFIER_assert((a == 1) && (b == 1));
23+
break;
24+
case 2:
25+
__VERIFIER_assert((a == 2) && (b == 4));
26+
break;
27+
case 3:
28+
__VERIFIER_assert((a == 3) && (b == 9));
29+
break;
30+
case 4:
31+
__VERIFIER_assert((a == 4) && (b == 16));
32+
break;
33+
case 5:
34+
__VERIFIER_assert((a == 5) && (b == 25));
35+
break;
36+
case 6:
37+
__VERIFIER_assert((a == 6) && (b == 36));
38+
break;
39+
case 7:
40+
__VERIFIER_assert((a == 7) && (b == 49));
41+
break;
42+
case 8:
43+
__VERIFIER_assert((a == 8) && (b == 64));
44+
break;
45+
case 9:
46+
__VERIFIER_assert((a == 9) && (b == 81));
47+
break;
48+
}
49+
}
50+
// END HARNESS
51+
52+
typedef struct example_user_t {
53+
int id;
54+
int cookie;
55+
UT_hash_handle hh;
56+
} example_user_t;
57+
58+
int main()
59+
{
60+
int i;
61+
example_user_t *user, *users=NULL;
62+
63+
/* create elements */
64+
for(i=0; i<10; i++) {
65+
user = (example_user_t*)malloc(sizeof(example_user_t));
66+
if (user == NULL) {
67+
exit(-1);
68+
}
69+
user->id = i;
70+
user->cookie = i*i;
71+
HASH_ADD_INT(users,id,user);
72+
}
73+
74+
for(user=users; user != NULL; user=(example_user_t*)(user->hh.next)) {
75+
test_int_int(user->id, user->cookie);
76+
}
77+
return 0;
78+
}

0 commit comments

Comments
 (0)