source: CIVL/examples/languageFeatures/removedHeapPointer.cvl

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 608 bytes
Line 
1/* This example shows that CIVL reports an error when
2 * the program tries to dereference a pointer referring
3 * to a unit of a heap that is already removed.
4 * Command line execution:
5 * civl verify removedHeapPointer.cvl
6 */
7#include <civlc.cvh>
8
9int *gp;
10_Bool gStart = $false;
11
12void foo(){
13 $scope sf = $here;
14
15 gp = (int *) $malloc(sf, sizeof(int));
16 gStart = $true;
17 *gp = 1;
18 $free(gp);
19}
20
21void goo(){
22 $when(gStart);
23 *gp = 2;// an error is possible when the process f has already returned.
24}
25
26void main(){
27 $proc f = $spawn foo();
28 $proc g = $spawn goo();
29
30 $wait(f);
31 $wait(g);
32}
Note: See TracBrowser for help on using the repository browser.