Skip to content

Commit 3e9c961

Browse files
Fix strange behaviour
1 parent d83cbf1 commit 3e9c961

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
@@ -3277,12 +3277,12 @@ class Traverser(
32773277
queuedSymbolicStateUpdates += mkNot(mkEq(symbolicResult.value.addr, nullObjectAddr)).asHardConstraint()
32783278
}
32793279

3280-
val state = environment.state.update(queuedSymbolicStateUpdates)
3281-
val memory = state.memory
3282-
val solver = state.solver
3280+
val symbolicState = environment.state.symbolicState + queuedSymbolicStateUpdates
3281+
val memory = symbolicState.memory
3282+
val solver = symbolicState.solver
32833283

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

32873287
if (holder !is UtSolverStatusSAT) {
32883288
logger.trace { "processResult<${environment.method.signature}> UNSAT" }
@@ -3291,7 +3291,7 @@ class Traverser(
32913291
val methodResult = MethodResult(symbolicResult)
32923292

32933293
//execution frame from level 2 or above
3294-
if (state.isInNestedMethod()) {
3294+
if (environment.state.isInNestedMethod()) {
32953295
// static fields substitution
32963296
// TODO: JIRA:1610 -- better way of working with statics
32973297
val updates = if (environment.method.name == STATIC_INITIALIZER && substituteStaticsWithSymbolicVariable) {
@@ -3302,15 +3302,17 @@ class Traverser(
33023302
} else {
33033303
MemoryUpdate() // all memory updates are already added in [environment.state]
33043304
}
3305-
val stateToOffer = state.pop(methodResult.copy(symbolicStateUpdate = updates.asUpdate()))
3305+
val methodResultWithUpdates = methodResult.copy(symbolicStateUpdate = queuedSymbolicStateUpdates + updates)
3306+
val stateToOffer = environment.state.pop(methodResultWithUpdates)
33063307
offerState(stateToOffer)
33073308

33083309
logger.trace { "processResult<${environment.method.signature}> return from nested method" }
33093310
return
33103311
}
33113312

33123313
//toplevel method
3313-
val terminalExecutionState = state.copy(
3314+
val terminalExecutionState = environment.state.copy(
3315+
symbolicState = symbolicState,
33143316
methodResult = methodResult, // the way to put SymbolicResult into terminal state
33153317
label = StateLabel.TERMINAL
33163318
)

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)