Skip to content

Commit a102624

Browse files
authored
Merge pull request #1682 from goblint/memleak-assert
Ensure that `__goblint_check` does not affect memLeak analysis
2 parents 118a1b8 + 6bdbed4 commit a102624

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/analyses/memLeak.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ struct
227227
(* Upon a call to the "Abort" special function in the multi-threaded case, we give up and conservatively warn *)
228228
warn_for_multi_threaded_due_to_abort man;
229229
state
230-
| Assert { exp; _ } ->
230+
| Assert { exp; refine = true; _ } ->
231231
begin match man.ask (Queries.EvalInt exp) with
232232
| a when Queries.ID.is_bot a -> M.warn ~category:Assert "assert expression %a is bottom" d_exp exp
233233
| a ->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// PARAM: --set ana.activated[+] memLeak --set ana.malloc.unique_address_count 1
2+
#include <stdlib.h>
3+
#include <goblint.h>
4+
5+
int main() {
6+
int *ptr = malloc(sizeof(int));
7+
__goblint_check(ptr == 0); // FAIL
8+
free(ptr);
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$ goblint --set ana.activated[+] memLeak --set ana.malloc.unique_address_count 1 32-no-mem-leak-goblint-check.c
2+
[Error][Assert] Assertion "(unsigned long )ptr == (unsigned long )((int *)0)" will fail. (32-no-mem-leak-goblint-check.c:7:5-7:30)
3+
[Info][Deadcode] Logical lines of code (LLoC) summary:
4+
live: 5
5+
dead: 0
6+
total lines: 5

tests/regression/76-memleak/dune

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(cram
2+
(deps (glob_files *.c)))

0 commit comments

Comments
 (0)