Skip to content

Commit

Permalink
Modular analysis: Add test that globals are not refined.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerhard committed Dec 8, 2023
1 parent 48291ad commit d85ef4b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/regression/79-modular/60-global-in-condition.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//PARAM: --set ana.modular.funs "['foo']" --set ana.activated[+] "'modular_queries'" --set ana.activated[+] "'is_modular'" --set ana.activated[+] "'written'" --set ana.activated[+] "'read'" --set ana.activated[+] "'used_globals'"

#include <pthread.h>
#include <stdlib.h>
#include <goblint.h>

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

int g = 4;

int foo(){
pthread_mutex_lock(&mutex);
if(g == 4){
pthread_mutex_unlock(&mutex);

pthread_mutex_lock(&mutex);
__goblint_check(g == 4); // UNKNOWN!
pthread_mutex_unlock(&mutex);
}
}

void *thread_f(void *arg){
foo();
return NULL;
}

int main(){;
pthread_t thread;
pthread_create(&thread, NULL, thread_f, NULL);

foo();

pthread_mutex_lock(&mutex);
g = 5;
pthread_mutex_unlock(&mutex);
}

0 comments on commit d85ef4b

Please sign in to comment.