Skip to content

Commit a9f2bae

Browse files
michael-schwarzkaroliinehsim642
authored
Port ~50 library specifications to the new system (#1200)
* `atoi` and friends * `htonl` and friends * `sleep` an friends * `strchr` and friends * `strcasecmp` and friend * `__builtin_strchr` * `memcmp` * `memchr` * `{set,get}priority` * `execl` * `clock` * `sem_init` * `sem_wait` and `sem_trywait` * Make `sem_wait*` consistent * `sem_post` * `sem_destroy` * `sched_yield` * `srand` * `getpid` * `getuid`, `geteuid` * `getpgrp` * `{set,get}rlimit` * `setsid` * `getdtablesize` * `isatty` * `__VERIFIER_nondet_int` * `sigemptyset` and friends * `sigprocmask` * `fork` * dynamic linking * `inet_addr` * `setsockopt` * `getsockname` * `socket` * `gethostbyname_r` * `gethostname` * `getpeername` * `uname` * `getopt_long` * Enable `svcomp` library functions where `racemacros.h` is included * 36/15 activate sv-comp libraries * Comment on `Sem*` specials that they are unused * Move `str[n]casecmp` to Posix group * Punctuation * Apply suggestions from code review Co-authored-by: Karoliine Holter <[email protected]> Co-authored-by: Simmo Saan <[email protected]> * Do not record accesses to `sem` * Move `getdtablesize` to `glibc` * Add `sema_init` back * Remove TODO --------- Co-authored-by: Karoliine Holter <[email protected]> Co-authored-by: Simmo Saan <[email protected]>
1 parent 7e57562 commit a9f2bae

Some content is hidden

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

55 files changed

+142
-103
lines changed

src/analyses/libraryDesc.ml

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ type special =
5858
| Broadcast of Cil.exp
5959
| MutexAttrSetType of { attr:Cil.exp; typ: Cil.exp; }
6060
| MutexInit of { mutex:Cil.exp; attr: Cil.exp; }
61+
(* All Sem specials are not used yet. *)
62+
| SemInit of { sem: Cil.exp; pshared: Cil.exp; value: Cil.exp; }
63+
| SemWait of { sem: Cil.exp; try_:bool; timeout: Cil.exp option;}
64+
| SemPost of Cil.exp
65+
| SemDestroy of Cil.exp
6166
| Wait of { cond: Cil.exp; mutex: Cil.exp; }
6267
| TimedWait of { cond: Cil.exp; mutex: Cil.exp; abstime: Cil.exp; (** Unused *) }
6368
| Math of { fun_args: math; }

src/analyses/libraryFunctions.ml

+64-56
Large diffs are not rendered by default.

tests/regression/28-race_reach/01-simple_racing.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -19,4 +20,4 @@ int main(void) {
1920
pthread_mutex_unlock(&mutex2);
2021
join_threads(t);
2122
return 0;
22-
}
23+
}

tests/regression/28-race_reach/02-simple_racefree.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -19,4 +20,4 @@ int main(void) {
1920
pthread_mutex_unlock(&mutex1);
2021
join_threads(t);
2122
return 0;
22-
}
23+
}

tests/regression/28-race_reach/03-munge_racing.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -26,4 +27,4 @@ int main(void) {
2627
create_threads(t1); create_threads(t2);
2728
join_threads(t1); join_threads(t2);
2829
return 0;
29-
}
30+
}

tests/regression/28-race_reach/04-munge_racefree.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -26,4 +27,4 @@ int main(void) {
2627
create_threads(t1); create_threads(t2);
2728
join_threads(t1); join_threads(t2);
2829
return 0;
29-
}
30+
}

tests/regression/28-race_reach/05-lockfuns_racefree.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -26,4 +27,4 @@ int main(void) {
2627
unlock();
2728
join_threads(t);
2829
return 0;
29-
}
30+
}

tests/regression/28-race_reach/06-cond_racing1.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include<stdio.h>
23
#include<pthread.h>
34

@@ -31,7 +32,3 @@ int main() {
3132
join_threads(t);
3233
return 0;
3334
}
34-
35-
36-
37-

tests/regression/28-race_reach/07-cond_racing2.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include<stdio.h>
23
#include<pthread.h>
34
#include "racemacros.h"

tests/regression/28-race_reach/08-cond_racefree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include<stdio.h>
23
#include<pthread.h>
34
#include "racemacros.h"

tests/regression/28-race_reach/09-ptrmunge_racing.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -27,4 +28,4 @@ int main(void) {
2728
create_threads(t1); create_threads(t2);
2829
join_threads(t1); join_threads(t2);
2930
return 0;
30-
}
31+
}

tests/regression/28-race_reach/10-ptrmunge_racefree.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -27,4 +28,4 @@ int main(void) {
2728
create_threads(t1); create_threads(t2);
2829
join_threads(t1); join_threads(t2);
2930
return 0;
30-
}
31+
}

tests/regression/28-race_reach/11-ptr_racing.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -20,4 +21,4 @@ int main(void) {
2021
pthread_mutex_unlock(&mutex2);
2122
join_threads(t);
2223
return 0;
23-
}
24+
}

tests/regression/28-race_reach/12-ptr_racefree.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -16,8 +17,8 @@ void *t_fun(void *arg) {
1617
int main(void) {
1718
create_threads(t);
1819
pthread_mutex_lock(&mutex1);
19-
assert_racefree(global);
20+
assert_racefree(global);
2021
pthread_mutex_unlock(&mutex1);
2122
join_threads(t);
2223
return 0;
23-
}
24+
}

tests/regression/28-race_reach/19-callback_racing.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
extern int __VERIFIER_nondet_int();
23

34
#include<pthread.h>

tests/regression/28-race_reach/20-callback_racefree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
extern int __VERIFIER_nondet_int();
23

34
#include<pthread.h>

tests/regression/28-race_reach/21-deref_read_racing.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/22-deref_read_racefree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/23-sound_unlock_racing.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/24-sound_lock_racing.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/27-funptr_racing.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include <stdio.h>
34
#include "racemacros.h"
45

56
int global;
67
pthread_mutex_t gm = PTHREAD_MUTEX_INITIALIZER;
78

8-
void bad() {
9+
void bad() {
910
access(global);
1011
}
1112

12-
void good() {
13+
void good() {
1314
pthread_mutex_lock(&gm);
1415
access(global);
1516
pthread_mutex_unlock(&gm);
@@ -42,4 +43,4 @@ int main() {
4243

4344
join_threads(t);
4445
return 0;
45-
}
46+
}

tests/regression/28-race_reach/28-funptr_racefree.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include <stdio.h>
34
#include "racemacros.h"
45

56
int global = 0;
67
pthread_mutex_t gm = PTHREAD_MUTEX_INITIALIZER;
78

8-
void bad() {
9+
void bad() {
910
access(global);
10-
}
11-
void good() {
11+
}
12+
void good() {
1213
pthread_mutex_lock(&gm);
1314
access(global);
1415
pthread_mutex_unlock(&gm);
@@ -41,4 +42,4 @@ int main() {
4142

4243
join_threads(t);
4344
return 0;
44-
}
45+
}

tests/regression/28-race_reach/36-indirect_racefree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/37-indirect_racing.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/40-trylock_racing.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -25,4 +26,4 @@ int main(void) {
2526
pthread_mutex_unlock(&mutex); // no UB because ERRORCHECK
2627
join_threads(t);
2728
return 0;
28-
}
29+
}

tests/regression/28-race_reach/41-trylock_racefree.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -22,4 +23,4 @@ int main(void) {
2223
pthread_mutex_unlock(&mutex);
2324
join_threads(t);
2425
return 0;
25-
}
26+
}

tests/regression/28-race_reach/42-trylock2_racefree.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

@@ -35,4 +36,4 @@ int main(void) {
3536

3637
join_threads(t);
3738
return 0;
38-
}
39+
}

tests/regression/28-race_reach/45-escape_racing.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/46-escape_racefree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/51-mutexptr_racefree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include <pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/60-invariant_racefree.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include<pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/61-invariant_racing.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// PARAM: --set lib.activated[+] sv-comp
12
#include<pthread.h>
23
#include "racemacros.h"
34

tests/regression/28-race_reach/70-funloop_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/71-funloop_racing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/72-funloop_hard_racing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/73-funloop_hard_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/74-tricky_address1_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/75-tricky_address2_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/76-tricky_address3_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/77-tricky_address4_racing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdio.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/78-equ_racing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdlib.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/79-equ_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'"
1+
// PARAM: --enable ana.race.direct-arithmetic --set ana.activated[+] "'var_eq'" --set ana.activated[+] "'symb_locks'" --set lib.activated[+] sv-comp
22
#include<pthread.h>
33
#include<stdlib.h>
44
#include "racemacros.h"

tests/regression/28-race_reach/81-list_racing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --set ana.activated[+] "'region'"
1+
// PARAM: --set ana.activated[+] "'region'" --set lib.activated[+] sv-comp
22
#include<stdlib.h>
33
#include "racemacros.h"
44

tests/regression/28-race_reach/82-list_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --set ana.activated[+] "'region'"
1+
// PARAM: --set ana.activated[+] "'region'" --set lib.activated[+] sv-comp
22
#include<stdlib.h>
33
#include "racemacros.h"
44

tests/regression/28-race_reach/83-list2_racing1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --set ana.activated[+] "'region'"
1+
// PARAM: --set ana.activated[+] "'region'" --set lib.activated[+] sv-comp
22
#include<stdlib.h>
33
#include "racemacros.h"
44

tests/regression/28-race_reach/84-list2_racing2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --set ana.activated[+] "'region'"
1+
// PARAM: --set ana.activated[+] "'region'" --set lib.activated[+] sv-comp
22
#include<stdlib.h>
33
#include "racemacros.h"
44

tests/regression/28-race_reach/85-list2_racefree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --set ana.activated[+] "'region'"
1+
// PARAM: --set ana.activated[+] "'region'" --set lib.activated[+] sv-comp
22
#include<stdlib.h>
33
#include "racemacros.h"
44

tests/regression/28-race_reach/86-lists_racing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PARAM: --set ana.activated[+] "'region'"
1+
// PARAM: --set ana.activated[+] "'region'" --set lib.activated[+] sv-comp
22
#include<stdlib.h>
33
#include "racemacros.h"
44

0 commit comments

Comments
 (0)