Skip to content

Handle escaping of locals (after thread-creation/via globals) soundly #246

@jerhard

Description

@jerhard

Goblint does not handle the case when a local variable escapes to another thread after the thread has been started.
A local may become reachable for a thread after the thread has been created, e.g. if the ego-thread stores its address in an object reachable from the parameters passed to the created thread.

The following is an example where this happens:

void *foo(void* p){
sleep(2);
int* ip = *((int**) p);
printf("ip is %d\n", *ip);
*ip = 42;
return NULL;
}
int main(){
int x = 0;
int *xp = &x;
int** ptr = &xp;
int x2 = 35;
pthread_t thread;
pthread_create(&thread, NULL, foo, ptr);
*ptr = &x2;
sleep(4); // to make sure that we actually fail the assert when running.
assert(x2 == 35); // UNKNOWN!
pthread_join(thread, NULL);
return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions