-
Notifications
You must be signed in to change notification settings - Fork 87
Handle escaping of locals (after thread-creation/via globals) soundly #246
Copy link
Copy link
Closed
Description
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:
analyzer/tests/regression/37-escape/01-local-in-pthread.c
Lines 9 to 29 in 4be9ab0
| 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; | |
| } |
Reactions are currently unavailable