Showing error 2213

User: Jiri Slaby
Error type: Reachable Error Location
Error type description: A specified error location is reachable in some program path
File location: pthread/twostage_3_unsafe.i
Line in file: 1349
Project: SV-COMP 2013
Project version: 2.6.28
Tools: Manual Work
Entered: 2013-01-17 16:57:54 UTC


Source:

1319static int data1Value = 0;
1320static int data2Value = 0;
1321pthread_mutex_t *data1Lock;
1322pthread_mutex_t *data2Lock;
1323void lock(pthread_mutex_t *);
1324void unlock(pthread_mutex_t *);
1325void *funcA(void *param) {
1326    pthread_mutex_lock(data1Lock);
1327    data1Value = 1;
1328    pthread_mutex_unlock(data1Lock);
1329    pthread_mutex_lock(data2Lock);
1330    data2Value = data1Value + 1;
1331    pthread_mutex_unlock(data2Lock);
1332    return ((void *)0);
1333}
1334void *funcB(void *param) {
1335    int t1 = -1;
1336    int t2 = -1;
1337    pthread_mutex_lock(data1Lock);
1338    if (data1Value == 0) {
1339        pthread_mutex_unlock(data1Lock);
1340        return ((void *)0);
1341    }
1342    t1 = data1Value;
1343    pthread_mutex_unlock(data1Lock);
1344    pthread_mutex_lock(data2Lock);
1345    t2 = data2Value;
1346    pthread_mutex_unlock(data2Lock);
1347    if (t2 != (t1 + 1)) {
1348        fprintf(stderr, "Bug found!\n");
1349 ERROR: goto ERROR;
1350          ;
1351    }
1352    return ((void *)0);
1353}
1354int main(int argc, char *argv[]) {
1355    int i,err;
1356    if (argc != 1) {
1357        if (argc != 3) {
1358            fprintf(stderr, "./twostage <param1> <param2>\n");
1359            exit(-1);
Show full sources