Skip to content

Commit bb1e7aa

Browse files
committed
Fix exp.single-threaded spawning errors
1. Don't output final message if no thread creations are even attempted by the program. 2. Output non-final message for each suppressed thread.
1 parent 354f523 commit bb1e7aa

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/analyses/mCP.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@ struct
149149

150150
let do_spawns man (xs:(varinfo * (lval option * exp list * bool)) list) =
151151
let spawn_one v d =
152-
List.iter (fun (lval, args, multiple) -> man.spawn ~multiple lval v args) d
152+
if get_bool "exp.single-threaded" then (
153+
M.msg_final Error ~category:Unsound "Thread not spawned";
154+
M.error ~category:Unsound "Thread not spawned from %a" CilType.Varinfo.pretty v
155+
)
156+
else
157+
List.iter (fun (lval, args, multiple) -> man.spawn ~multiple lval v args) d
153158
in
154-
if get_bool "exp.single-threaded" then
155-
M.msg_final Error ~category:Unsound "Thread not spawned" (* TODO: non-final error *) (* TODO: only final error if xs is non-empty *)
156-
else
157-
iter (uncurry spawn_one) @@ group_assoc_eq Basetype.Variables.equal xs
159+
iter (uncurry spawn_one) @@ group_assoc_eq Basetype.Variables.equal xs
158160

159161
let do_sideg man (xs:(V.t * (WideningTokenLifter.TS.t * G.t)) list) =
160162
let side_one v dts =

tests/regression/00-sanity/42-no-threadflag.t

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Assertions should succeed, race should not be present.
3333
live: 5
3434
dead: 0
3535
total lines: 5
36-
[Error][Unsound] Thread not spawned
3736

3837

3938
With single-threaded mode forced, but earlyglobs enabled.
@@ -46,5 +45,4 @@ Assertions should be unknown, race should not be present.
4645
live: 5
4746
dead: 0
4847
total lines: 5
49-
[Error][Unsound] Thread not spawned
5048

tests/regression/00-sanity/43-no-escape.t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ Assertions should succeed.
2626
live: 7
2727
dead: 0
2828
total lines: 7
29-
[Error][Unsound] Thread not spawned
3029

tests/regression/02-base/32-single-thr.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[Error][Imprecise][Unsound] Function definition missing for no_spawn (32-single-thr.c:12:3-12:15)
33
[Info][Imprecise] INVALIDATING ALL GLOBALS! (32-single-thr.c:12:3-12:15)
44
[Info][Imprecise] Invalidating expressions: & g, (void *)(& f) (32-single-thr.c:12:3-12:15)
5+
[Error][Unsound] Thread not spawned from f (32-single-thr.c:12:3-12:15)
56
[Warning][Deadcode] Function 'f' is uncalled: 2 LLoC (32-single-thr.c:6:1-8:1)
67
[Info][Deadcode] Logical lines of code (LLoC) summary:
78
live: 4

0 commit comments

Comments
 (0)