@@ -1165,7 +1165,7 @@ void __CPROVER_contracts_make_invalid_pointer(void **ptr)
1165
1165
1166
1166
/// \brief Implementation of the `is_fresh` front-end predicate.
1167
1167
///
1168
- /// The behaviour depends on the boolean flags carried by \p set
1168
+ /// The behaviour depends on the boolean flags carried by \p write_set
1169
1169
/// which reflect the invocation context: checking vs. replacing a contract,
1170
1170
/// in a requires or an ensures clause context.
1171
1171
/// \param elem First argument of the `is_fresh` predicate
@@ -1232,6 +1232,13 @@ __CPROVER_HIDE:;
1232
1232
__CPROVER_assume (size <= __CPROVER_max_malloc_size );
1233
1233
}
1234
1234
1235
+ // SOUNDNESS: allow predicate to fail
1236
+ if (__VERIFIER_nondet___CPROVER_bool ())
1237
+ {
1238
+ __CPROVER_contracts_make_invalid_pointer (elem );
1239
+ return 0 ;
1240
+ }
1241
+
1235
1242
void * ptr = __CPROVER_allocate (size , 0 );
1236
1243
* elem = ptr ;
1237
1244
@@ -1245,7 +1252,6 @@ __CPROVER_HIDE:;
1245
1252
// __CPROVER_bool record_may_leak = __VERIFIER_nondet___CPROVER_bool();
1246
1253
// __CPROVER_memory_leak = record_may_leak ? ptr : __CPROVER_memory_leak;
1247
1254
1248
- // record fresh object in the object set
1249
1255
#ifdef __CPROVER_DFCC_DEBUG_LIB
1250
1256
// manually inlined below
1251
1257
__CPROVER_contracts_obj_set_add (write_set -> linked_is_fresh , ptr );
@@ -1286,6 +1292,13 @@ __CPROVER_HIDE:;
1286
1292
__CPROVER_assume (size <= __CPROVER_max_malloc_size );
1287
1293
}
1288
1294
1295
+ // SOUNDNESS: allow predicate to fail
1296
+ if (__VERIFIER_nondet___CPROVER_bool ())
1297
+ {
1298
+ __CPROVER_contracts_make_invalid_pointer (elem );
1299
+ return 0 ;
1300
+ }
1301
+
1289
1302
void * ptr = __CPROVER_allocate (size , 0 );
1290
1303
* elem = ptr ;
1291
1304
@@ -1300,7 +1313,6 @@ __CPROVER_HIDE:;
1300
1313
__CPROVER_bool record_may_leak = __VERIFIER_nondet___CPROVER_bool ();
1301
1314
__CPROVER_memory_leak = record_may_leak ? ptr : __CPROVER_memory_leak ;
1302
1315
1303
- // record fresh object in the caller's write set
1304
1316
#ifdef __CPROVER_DFCC_DEBUG_LIB
1305
1317
__CPROVER_contracts_obj_set_add (write_set -> linked_allocated , ptr );
1306
1318
#else
@@ -1338,7 +1350,7 @@ __CPROVER_HIDE:;
1338
1350
if (seen -> elems [object_id ] != 0 )
1339
1351
return 0 ;
1340
1352
#endif
1341
- // record fresh object in the object set
1353
+
1342
1354
#ifdef __CPROVER_DFCC_DEBUG_LIB
1343
1355
// manually inlined below
1344
1356
__CPROVER_contracts_obj_set_add (seen , ptr );
@@ -1360,6 +1372,23 @@ __CPROVER_HIDE:;
1360
1372
}
1361
1373
}
1362
1374
1375
+ /// \brief Implementation of the `pointer_in_range_dfcc` front-end predicate.
1376
+ ///
1377
+ /// The behaviour depends on the boolean flags carried by \p write_set
1378
+ /// which reflect the invocation context: checking vs. replacing a contract,
1379
+ /// in a requires or an ensures clause context.
1380
+ /// \param lb Lower bound pointer
1381
+ /// \param ptr Target pointer of the predicate
1382
+ /// \param ub Upper bound pointer
1383
+ /// \param write_set Write set in which seen/allocated objects are recorded;
1384
+ ///
1385
+ /// \details The behaviour is as follows:
1386
+ /// - When \p set->assume_requires_ctx or \p set->assume_ensures_ctx is `true`,
1387
+ /// the predicate checks that \p lb and \p ub are valid, into the same object,
1388
+ /// ordered, and checks that \p ptr is between \p lb and \p ub.
1389
+ /// - When \p set->assert_requires_ctx or \p set->assert_ensures_ctx is `true`,
1390
+ /// the predicate checks that \p lb and \p ub are valid, into the same object,
1391
+ /// ordered, and assigns \p ptr to some nondet offset between \p lb and \p ub.
1363
1392
__CPROVER_bool __CPROVER_contracts_pointer_in_range_dfcc (
1364
1393
void * lb ,
1365
1394
void * * ptr ,
@@ -1386,7 +1415,11 @@ __CPROVER_HIDE:;
1386
1415
if (write_set -> assume_requires_ctx | write_set -> assume_ensures_ctx )
1387
1416
{
1388
1417
if (__VERIFIER_nondet___CPROVER_bool ())
1418
+ {
1419
+ // SOUNDNESS: allow predicate to fail
1420
+ __CPROVER_contracts_make_invalid_pointer (ptr );
1389
1421
return 0 ;
1422
+ }
1390
1423
1391
1424
// add nondet offset
1392
1425
__CPROVER_size_t offset = __VERIFIER_nondet_size ();
0 commit comments