Skip to content

Commit 3f4a6bc

Browse files
authored
Merge pull request #1307 from goblint/issue-1260
Suppress thread-unsafe library function calls in single-threaded mode
2 parents ea1bf23 + ecd0bc5 commit 3f4a6bc

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

src/analyses/raceAnalysis.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ struct
369369
let special ctx (lvalOpt: lval option) (f:varinfo) (arglist:exp list) : D.t =
370370
(* perform shallow and deep invalidate according to Library descriptors *)
371371
let desc = LibraryFunctions.find f in
372-
if List.mem LibraryDesc.ThreadUnsafe desc.attrs then (
372+
if List.mem LibraryDesc.ThreadUnsafe desc.attrs && ThreadFlag.is_currently_multi (Analyses.ask_of_ctx ctx) then (
373373
let exp = Lval (Var f, NoOffset) in
374374
let conf = 110 in
375375
let kind = AccessKind.Call in
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// PARAM: --enable allglobs --set ana.activated[+] threadJoins
2+
#include <stdlib.h>
3+
#include <pthread.h>
4+
5+
void *t_benign(void *arg) {
6+
return NULL;
7+
}
8+
9+
int main() {
10+
rand();
11+
pthread_t id;
12+
pthread_create(&id, NULL, t_benign, NULL);
13+
pthread_join(id, NULL);
14+
rand();
15+
return 0;
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$ goblint --enable allglobs --set ana.activated[+] threadJoins 52-thread-unsafe-libfuns-single-thread.c
2+
[Info][Deadcode] Logical lines of code (LLoC) summary:
3+
live: 8
4+
dead: 0
5+
total lines: 8

tests/regression/29-svcomp/32-no-ov.t

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,3 @@
99
dead: 0
1010
total lines: 3
1111
SV-COMP result: true
12-
[Info][Race] Memory locations race summary:
13-
safe: 1
14-
vulnerable: 0
15-
unsafe: 0
16-
total memory locations: 1

0 commit comments

Comments
 (0)