Skip to content

Ensure that __goblint_check does not affect memLeak analysis #1682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analyses/memLeak.ml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct
(* Upon a call to the "Abort" special function in the multi-threaded case, we give up and conservatively warn *)
warn_for_multi_threaded_due_to_abort man;
state
| Assert { exp; _ } ->
| Assert { exp; refine = true; _ } ->
begin match man.ask (Queries.EvalInt exp) with
| a when Queries.ID.is_bot a -> M.warn ~category:Assert "assert expression %a is bottom" d_exp exp
| a ->
Expand Down
9 changes: 9 additions & 0 deletions tests/regression/76-memleak/32-no-mem-leak-goblint-check.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// PARAM: --set ana.activated[+] memLeak --set ana.malloc.unique_address_count 1
#include <stdlib.h>
#include <goblint.h>

int main() {
int *ptr = malloc(sizeof(int));
__goblint_check(ptr == 0); // FAIL
free(ptr);
}
6 changes: 6 additions & 0 deletions tests/regression/76-memleak/32-no-mem-leak-goblint-check.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$ goblint --set ana.activated[+] memLeak --set ana.malloc.unique_address_count 1 32-no-mem-leak-goblint-check.c
[Error][Assert] Assertion "(unsigned long )ptr == (unsigned long )((int *)0)" will fail. (32-no-mem-leak-goblint-check.c:7:5-7:30)
[Info][Deadcode] Logical lines of code (LLoC) summary:
live: 5
dead: 0
total lines: 5
2 changes: 2 additions & 0 deletions tests/regression/76-memleak/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(cram
(deps (glob_files *.c)))
Loading