Skip to content

Protection-Based Privatization more Precise than Write-Centered #1456

@michael-schwarz

Description

@michael-schwarz

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).

#include<pthread.h>
#include<stdlib.h>
struct a {
  struct a *b;
  struct a *c;
};

struct a i;

pthread_mutex_t m;

void doit() {
  void *newa = malloc(sizeof(struct a));

  pthread_mutex_lock(&m);
  i.c->b = newa;
  i.c = newa;
  pthread_mutex_unlock(&m);
}

void* k(void *arg) {
  doit();
  return NULL;
}

int main() {
    struct a other;
    i.c = &other;

    pthread_t t1;
    pthread_create(&t1, 0, k, 0);

    doit();
    return 0;
}

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:

[Debug] 2.c:17:3-17:13 (alloc@sid:10@tid:[main]): protection more precise than write
  protection: {
                b -> {&(alloc@sid:10@tid:[main])}
                c -> Uninitialized
              }
  more precise than
  write: (value:{
                  b -> {&(alloc@sid:10@tid:[main]), &(alloc@sid:10@tid:[main, [email protected]:31:5-31:33])}
                  c -> Uninitialized
                }, size:(16,[16,16],{16}), no zeroinit:true)
  reverse diff: compound: (value:{
                                   b -> {&(alloc@sid:10@tid:[main]), &(alloc@sid:10@tid:[main, [email protected]:31:5-31:33])}
                                   c -> Uninitialized
                                 }, size:(16,[16,16],{16}), no zeroinit:true) not same type as {
                                                                                                   b -> {&(alloc@sid:10@tid:[main])}
                                                                                                   c -> Uninitialized
                                                                                                 }

[Debug] 2.c:17:3-17:13 (alloc@sid:10@tid:[main, [email protected]:31:5-31:33]): protection more precise than write
  protection: {
                b -> {&(alloc@sid:10@tid:[main, [email protected]:31:5-31:33])}
                c -> Uninitialized
              }
  more precise than
  write: (value:{
                  b -> {&(alloc@sid:10@tid:[main]), &(alloc@sid:10@tid:[main, [email protected]:31:5-31:33])}
                  c -> Uninitialized
                }, size:(16,[16,16],{16}), no zeroinit:true)
  reverse diff: compound: (value:{
                                   b -> {&(alloc@sid:10@tid:[main]), &(alloc@sid:10@tid:[main, [email protected]:31:5-31:33])}
                                   c -> Uninitialized
                                 }, size:(16,[16,16],{16}), no zeroinit:true) not same type as {
                                                                                                   b -> {&(alloc@sid:10@tid:[main, [email protected]:31:5-31:33])}
                                                                                                   c -> Uninitialized
                                                                                                 }

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions