-
Notifications
You must be signed in to change notification settings - Fork 75
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
Protection-Based Privatization more Precise than Write-Centered #1456
Comments
I find the blob vs no-blob difference already quite noteworthy. The two differences correspond to the two cases that have been merged in the blob. I think if the types matched for both (either both blobs or non-blobs), then they should both be merged or unmerged and the difference should disappear. |
After some further simplification, we end up with #include<pthread.h>
#include<stdlib.h>
struct a {
struct a *b;
};
struct a *ptr;
pthread_mutex_t m;
void doit() {
void *newa = malloc(sizeof(struct a));
pthread_mutex_lock(&m);
ptr->b = newa;
ptr = newa;
pthread_mutex_unlock(&m);
}
void* k(void *arg) {
doit();
return NULL;
}
int main() {
struct a other;
ptr = &other;
pthread_t t1;
pthread_create(&t1, 0, k, 0);
doit();
return 0;
} |
I experimentally disabled widening, and as assumed, this problem is unrelated to widening. |
It seems that, in fact, in the concrete, the variable can never have the value
claimed by the more precise privatization, as |
With #1458, the original example works here. However, we get a new counterexample: #include<pthread.h>
struct a {
char* b;
};
struct a *c;
struct a h = {""};
struct a i = {"string"};
void* d(void* args) {
struct a r;
if (c->b)
r = *c;
}
int main() {
int top;
if(top) {
c = &h;
} else {
c = &i;
}
pthread_t t;
pthread_create(&t, 0, d, 0);
return 0;
}
|
With this modification, it is even observable as an assertion failing resp. succeeding: // PARAM: --set ana.base.privatization write
#include<pthread.h>
struct a {
char* b;
};
struct a *c;
struct a h = {""};
struct a i = {"string"};
void* d(void* args) {
struct a r;
if (c->b) {
__goblint_check(strlen(h.b) == 0); // Works for protection
}
}
int main() {
int top;
if(top) {
c = &h;
} else {
c = &i;
}
pthread_t t;
pthread_create(&t, 0, d, 0);
return 0;
} |
Lines 1616 to 1625 in bffc5e3
|
There is something strange going on with the meet:
|
There remains at least one case of this. I did a creduce run on it overnight, but I'll have to see whether it came up with something useful. |
The resulting program now is #include<pthread.h>
#include<stdlib.h>
#include<string.h>
union g {
int h;
char i;
};
struct j {
union g data;
};
struct j *jptr;
void* af(void* arg) {
jptr = (struct j*) malloc(sizeof(struct j));
memset(jptr, 0, sizeof(struct j));
while (1) {
if (jptr->data.i)
;
}
}
void main() {
pthread_t ah;
pthread_create(&ah, 0, af, 0);
} where we have
|
All instances of this for domains not requiring widening are now resolved. For intervals, we have small examples where one can understand the seemingly paradoxical precision relationship by tracing and understanding how widening happens. |
Starting from minimizing one of the larger programs, I have now arrived at this example program, where the Protection-Based Privatization is more precise than the Write-Centered (without intervals or other domains that require a widening).
The program compiles with GCC and runs without segfaults.
Script to run comparison:
./goblint --conf conf/traces.json --set ana.base.privatization protection 2.c --enable allglobs --enable dbg.timing.enabled --enable warn.debug -v --sets exp.priv-prec-dump level-ip.protection.prec && ./goblint --conf conf/traces.json --set ana.base.privatization write 2.c --enable allglobs --enable dbg.timing.enabled --enable warn.debug -v --sets exp.priv-prec-dump level-ip.write.prec && ./privPrecCompare level-ip.protection.prec level-ip.write.prec &> out.txt
The diff output is:
The difference because of blob / no-blob is disregarded by the comparison, so the issue of interest seem to be the points-to sets that are smaller for
protection
.This already is on my branch (c.f. #1417) where a lot of the critical precision-comparison issues should be solved.
The text was updated successfully, but these errors were encountered: