| 1 | /*****************************************************************************
|
|---|
| 2 | * SOURCE: This is a translation of a Pthread program from
|
|---|
| 3 | * the Pthread benchmarks of SV-COMP 2014.
|
|---|
| 4 | * https://svn.sosy-lab.org/software/sv-benchmarks/tags/svcomp14/
|
|---|
| 5 | * FILE: fib_bench_false.cvl
|
|---|
| 6 | * DESCRIPTION:
|
|---|
| 7 | * Simple program of threads interacting which causes an error when
|
|---|
| 8 | * their total reaches a certain value. The fix simply involves changing the output
|
|---|
| 9 | * for which an error will be caused; specifically, here error is caused when i or j
|
|---|
| 10 | * >=144, the fix has i or j > 144.
|
|---|
| 11 | * Command line execution:
|
|---|
| 12 | * civl verify -inputNUM=5 fib_bench_false.cvl
|
|---|
| 13 | ******************************************************************************/
|
|---|
| 14 |
|
|---|
| 15 | #include <civlc.h>
|
|---|
| 16 | #include "pthread.cvh"
|
|---|
| 17 |
|
|---|
| 18 | int i=1, j=1;
|
|---|
| 19 |
|
|---|
| 20 | $input int NUM;
|
|---|
| 21 |
|
|---|
| 22 | void *t1(void* arg)
|
|---|
| 23 | {
|
|---|
| 24 | int k = 0;
|
|---|
| 25 |
|
|---|
| 26 | for (k = 0; k < NUM; k++)
|
|---|
| 27 | i+=j;
|
|---|
| 28 | pthread_exit(NULL, false, NULL, 0); //Different parameters
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | void *t2(void* arg)
|
|---|
| 32 | {
|
|---|
| 33 | int k = 0;
|
|---|
| 34 |
|
|---|
| 35 | for (k = 0; k < NUM; k++)
|
|---|
| 36 | j+=i;
|
|---|
| 37 | pthread_exit(NULL, false, NULL, 0);
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | int main(int argc, char **argv)
|
|---|
| 41 | {
|
|---|
| 42 | pthread_t id1, id2;
|
|---|
| 43 |
|
|---|
| 44 | pthread_create(&id1, NULL, t1, NULL);
|
|---|
| 45 | pthread_create(&id2, NULL, t2, NULL);
|
|---|
| 46 |
|
|---|
| 47 | pthread_join(id1, NULL); //Added pthread_join, probably error in competition code
|
|---|
| 48 | pthread_join(id2, NULL);
|
|---|
| 49 |
|
|---|
| 50 | if (i >= 144 || j >= 144) {
|
|---|
| 51 | $assert($false, "Incorrect output");
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | return 0;
|
|---|
| 55 | }
|
|---|