-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#197, add example that summarizes one alleged reason why the heap sep…
…arator does not separate well, currently
- Loading branch information
1 parent
2dedfb1
commit 87f1479
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
trunk/examples/programs/heapseparator/difficulty-dangling-dead-pointer-01.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Currently (09.01.2018), the heap separator cannot separate the memory array | ||
* in this example, although there is a semantics-preserving separation. | ||
* (partition would be {{p}, {q,r}}) | ||
* Combination of triggers for this problem: | ||
* - r is used to access the memory array, thus it is taken into account for | ||
* partitioning. | ||
* - r has a nondeterministic value at the positions where p and q are | ||
* dereferenced, it dangles between the potential partition blocks so to say, | ||
* and thus triggers their unification. | ||
*/ | ||
int * nondet() { | ||
int *i; | ||
return i; | ||
} | ||
|
||
int main() { | ||
|
||
int *p = malloc(sizeof(int)); | ||
int *q = malloc(sizeof(int)); | ||
|
||
int *r = q; | ||
int z = *r; | ||
r = nondet(); | ||
|
||
int x = *p; | ||
int y = *q; | ||
} |