Skip to content

Commit 4c9e733

Browse files
authored
Merge pull request #705 from viperproject/meilers_check_timeout_and_failure_gen
Fix timeouts and failure generation
2 parents 3fd88d5 + 2368ca1 commit 4c9e733

6 files changed

Lines changed: 25 additions & 19 deletions

File tree

src/main/scala/decider/Decider.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait Decider {
3434
def pushScope(): Unit
3535
def popScope(): Unit
3636

37-
def checkSmoke(): Boolean
37+
def checkSmoke(isAssert: Boolean = false): Boolean
3838

3939
def setCurrentBranchCondition(t: Term, te: Option[ast.Exp] = None): Unit
4040
def setPathConditionMark(): Mark
@@ -236,7 +236,10 @@ trait DefaultDeciderProvider extends VerifierComponent { this: Verifier =>
236236

237237
/* Asserting facts */
238238

239-
def checkSmoke(): Boolean = prover.check(Verifier.config.checkTimeout.toOption) == Unsat
239+
def checkSmoke(isAssert: Boolean = false): Boolean = {
240+
val timeout = if (isAssert) Verifier.config.assertTimeout.toOption else Verifier.config.checkTimeout.toOption
241+
prover.check(timeout) == Unsat
242+
}
240243

241244
def check(t: Term, timeout: Int): Boolean = deciderAssert(t, Some(timeout))
242245

src/main/scala/rules/ChunkSupporter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ object chunkSupporter extends ChunkSupportRules {
126126
}
127127
}
128128
QS(s2.copy(h = s.h), h2, snap, v1)
129-
case _ if v1.decider.checkSmoke() =>
129+
case _ if v1.decider.checkSmoke(true) =>
130130
Success() // TODO: Mark branch as dead?
131131
case _ =>
132132
createFailure(ve, v1, s1, true)
@@ -227,7 +227,7 @@ object chunkSupporter extends ChunkSupportRules {
227227
findChunk[NonQuantifiedChunk](h.values, id, args, v) match {
228228
case Some(ch) if v.decider.check(IsPositive(ch.perm), Verifier.config.checkTimeout()) =>
229229
Q(s, ch.snap, v)
230-
case _ if v.decider.checkSmoke() =>
230+
case _ if v.decider.checkSmoke(true) =>
231231
Success() // TODO: Mark branch as dead?
232232
case _ =>
233233
createFailure(ve, v, s, true)

src/main/scala/rules/Executor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ object executor extends ExecutionRules {
403403
case assert @ ast.Assert(a: ast.FalseLit) =>
404404
/* "assert false" triggers a smoke check. If successful, we backtrack. */
405405
executionFlowController.tryOrFail0(s.copy(h = magicWandSupporter.getEvalHeap(s)), v)((s1, v1, QS) => {
406-
if (v1.decider.checkSmoke())
406+
if (v1.decider.checkSmoke(true))
407407
QS(s1.copy(h = s.h), v1)
408408
else
409409
createFailure(AssertFailed(assert) dueTo AssertionFalse(a), v1, s1, true)

src/main/scala/rules/MoreCompleteExhaleSupporter.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ object moreCompleteExhaleSupporter extends SymbolicExecutionRules {
144144
val relevantChunks = findChunksWithID[NonQuantifiedChunk](h.values, id).toSeq
145145

146146
if (relevantChunks.isEmpty) {
147-
if (v.decider.checkSmoke()) {
147+
if (v.decider.checkSmoke(true)) {
148148
Success() // TODO: Mark branch as dead?
149149
} else {
150-
createFailure(ve, v, s, true)
150+
createFailure(ve, v, s)
151151
}
152152
} else {
153153
summarise(s, relevantChunks, resource, args, v)((s1, snap, _, permSum, v1) =>
@@ -217,10 +217,9 @@ object moreCompleteExhaleSupporter extends SymbolicExecutionRules {
217217

218218
if (relevantChunks.isEmpty) {
219219
// if no permission is exhaled, return none
220-
if (v.decider.check(perms === NoPerm(), Verifier.config.checkTimeout())) {
221-
Q(s, h, None, v)
222-
} else {
223-
createFailure(ve, v, s)
220+
v.decider.assert(perms === NoPerm()){
221+
case true => Q(s, h, None, v)
222+
case false => createFailure(ve, v, s)
224223
}
225224
} else {
226225
if (!terms.utils.consumeExactRead(perms, s.constrainableARPs)) {

src/main/scala/rules/Producer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ object producer extends ProductionRules {
160160
// We will get an IllegalArgumentException from createSnapshotPair if sf(...) returns Unit.
161161
// This should never happen if we're in a reachable state, so here we check for that
162162
// (without timeout, since there is no fallback) and stop verifying the current branch.
163-
case _: IllegalArgumentException if v.decider.check(False(), 0) =>
163+
case _: IllegalArgumentException if v.decider.check(False(), Verifier.config.assertTimeout.getOrElse(0)) =>
164164
Unreachable()
165165
}
166166

src/main/scala/rules/QuantifiedChunkSupport.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,6 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
12241224
: VerificationResult = {
12251225

12261226
val resource = resourceAccess.res(s.program)
1227-
val failure = resourceAccess match {
1228-
case locAcc: ast.LocationAccess => createFailure(pve dueTo InsufficientPermission(locAcc), v, s)
1229-
case wand: ast.MagicWand => createFailure(pve dueTo MagicWandChunkNotFound(wand), v, s)
1230-
case _ => sys.error(s"Found resource $resourceAccess, which is not yet supported as a quantified resource.")
1231-
}
12321227
val chunkIdentifier = ChunkIdentifier(resource, s.program)
12331228

12341229
val chunkOrderHeuristics = optChunkOrderHeuristic match {
@@ -1240,6 +1235,11 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
12401235
}
12411236

12421237
if (s.exhaleExt) {
1238+
val failure = resourceAccess match {
1239+
case locAcc: ast.LocationAccess => createFailure(pve dueTo InsufficientPermission(locAcc), v, s)
1240+
case wand: ast.MagicWand => createFailure(pve dueTo MagicWandChunkNotFound(wand), v, s)
1241+
case _ => sys.error(s"Found resource $resourceAccess, which is not yet supported as a quantified resource.")
1242+
}
12431243
magicWandSupporter.transfer(s, permissions, failure, v)((s1, h1, rPerm, v1) => {
12441244
val (relevantChunks, otherChunks) =
12451245
quantifiedChunkSupporter.splitHeap[QuantifiedBasicChunk](h1, chunkIdentifier)
@@ -1313,7 +1313,11 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
13131313
val snap = ResourceLookup(resource, smDef1.sm, arguments, s2.program).convert(sorts.Snap)
13141314
Q(s2, h1, snap, v)
13151315
case (Incomplete(_), _, _) =>
1316-
failure
1316+
resourceAccess match {
1317+
case locAcc: ast.LocationAccess => createFailure(pve dueTo InsufficientPermission(locAcc), v, s)
1318+
case wand: ast.MagicWand => createFailure(pve dueTo MagicWandChunkNotFound(wand), v, s)
1319+
case _ => sys.error(s"Found resource $resourceAccess, which is not yet supported as a quantified resource.")
1320+
}
13171321
}
13181322
}
13191323
}
@@ -1417,7 +1421,7 @@ object quantifiedChunkSupporter extends QuantifiedChunkSupport {
14171421

14181422
v.decider.prover.comment("Final check if taken enough permissions")
14191423
success =
1420-
if (success.isComplete || v.decider.check(tookEnoughCheck, 0) /* This check is a must-check, i.e. an assert */)
1424+
if (success.isComplete || v.decider.check(tookEnoughCheck, Verifier.config.assertTimeout.getOrElse(0)) /* This check is a must-check, i.e. an assert */)
14211425
Complete()
14221426
else
14231427
success

0 commit comments

Comments
 (0)