Skip to content

Commit 3f01700

Browse files
Fix strange behaviour
1 parent c266e98 commit 3f01700

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,12 +3330,12 @@ class Traverser(
33303330
queuedSymbolicStateUpdates += mkNot(mkEq(symbolicResult.value.addr, nullObjectAddr)).asHardConstraint()
33313331
}
33323332

3333-
val state = environment.state.update(queuedSymbolicStateUpdates)
3334-
val memory = state.memory
3335-
val solver = state.solver
3333+
val symbolicState = environment.state.symbolicState + queuedSymbolicStateUpdates
3334+
val memory = symbolicState.memory
3335+
val solver = symbolicState.solver
33363336

33373337
//no need to respect soft constraints in NestedMethod
3338-
val holder = solver.check(respectSoft = !state.isInNestedMethod())
3338+
val holder = solver.check(respectSoft = !environment.state.isInNestedMethod())
33393339

33403340
if (holder !is UtSolverStatusSAT) {
33413341
logger.trace { "processResult<${environment.method.signature}> UNSAT" }
@@ -3344,7 +3344,7 @@ class Traverser(
33443344
val methodResult = MethodResult(symbolicResult)
33453345

33463346
//execution frame from level 2 or above
3347-
if (state.isInNestedMethod()) {
3347+
if (environment.state.isInNestedMethod()) {
33483348
// static fields substitution
33493349
// TODO: JIRA:1610 -- better way of working with statics
33503350
val updates = if (environment.method.name == STATIC_INITIALIZER && substituteStaticsWithSymbolicVariable) {
@@ -3355,15 +3355,17 @@ class Traverser(
33553355
} else {
33563356
MemoryUpdate() // all memory updates are already added in [environment.state]
33573357
}
3358-
val stateToOffer = state.pop(methodResult.copy(symbolicStateUpdate = updates.asUpdate()))
3358+
val methodResultWithUpdates = methodResult.copy(symbolicStateUpdate = queuedSymbolicStateUpdates + updates)
3359+
val stateToOffer = environment.state.pop(methodResultWithUpdates)
33593360
offerState(stateToOffer)
33603361

33613362
logger.trace { "processResult<${environment.method.signature}> return from nested method" }
33623363
return
33633364
}
33643365

33653366
//toplevel method
3366-
val terminalExecutionState = state.copy(
3367+
val terminalExecutionState = environment.state.copy(
3368+
symbolicState = symbolicState,
33673369
methodResult = methodResult, // the way to put SymbolicResult into terminal state
33683370
label = StateLabel.TERMINAL
33693371
)

utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,7 @@ class UtBotSymbolicEngine(
493493
val solver = state.solver
494494
val parameters = state.parameters.map { it.value }
495495
val symbolicResult = requireNotNull(state.methodResult?.symbolicResult) { "The state must have symbolicResult" }
496-
// it's free to make a check, because in the result is SAT, it should be already cached
497-
val holder = requireNotNull(solver.check(respectSoft = true) as? UtSolverStatusSAT) { "The state must be SAT!" }
496+
val holder = requireNotNull(solver.lastStatus as? UtSolverStatusSAT) { "The state must be SAT!" }
498497

499498
val predictedTestName = Predictors.testName.predict(state.path)
500499
Predictors.testName.provide(state.path, predictedTestName, "")

0 commit comments

Comments
 (0)