1.23
2.0
main
test-branch
|
Last change
on this file since 50f834b was f72f577, checked in by John Edenhofner <johneden@…>, 12 years ago |
|
Added support for robust mutex, get/sets for pthread_mutexattr_t fields, pthread_mutex_trylock, and multiple new competition code examples
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@1073 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
591 bytes
|
| Line | |
|---|
| 1 | #include <stdlib.h>
|
|---|
| 2 | #include <pthread.h>
|
|---|
| 3 | #include <string.h>
|
|---|
| 4 |
|
|---|
| 5 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: goto ERROR; }; return; }
|
|---|
| 6 |
|
|---|
| 7 | char *v;
|
|---|
| 8 |
|
|---|
| 9 | void *thread1(void * arg)
|
|---|
| 10 | {
|
|---|
| 11 | v = malloc(sizeof(char) * 8);
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | void *thread2(void *arg)
|
|---|
| 15 | {
|
|---|
| 16 | if (v) strcpy(v, "Bigshot");
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 | int main()
|
|---|
| 21 | {
|
|---|
| 22 | pthread_t t1, t2;
|
|---|
| 23 |
|
|---|
| 24 | pthread_create(&t1, 0, thread1, 0);
|
|---|
| 25 | pthread_join(t1, 0);
|
|---|
| 26 |
|
|---|
| 27 | pthread_create(&t2, 0, thread2, 0);
|
|---|
| 28 | pthread_join(t2, 0);
|
|---|
| 29 |
|
|---|
| 30 | __VERIFIER_assert(v[0] == 'B'); // <---- wrong, malloc() can fail and therefore no strcpy!
|
|---|
| 31 |
|
|---|
| 32 | return 0;
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.